1

I'm making a Net::HTTP::Post request to a server to get some json response back from it.

The request has a JSON body.

I'm getting end of file reached error rarely.

Here is my code for the http request

http = Net::HTTP.new(full_uri.host, full_uri.port)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.use_ssl = true if full_uri.scheme =='https'

request = Net::HTTP::Post.new(full_uri.path, {})
request.content_type = 'application/json'
request.body = {:opportunity_id=>"006N0000004S2uVIAS"}.to_json.html_safe

http.request(request)

After I receive the response for this request., I get the following error.

end of file reached

BackTrace:

[  0] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/openssl/buffering.rb:182:in `sysread_nonblock'",
[  1] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/openssl/buffering.rb:182:in `read_nonblock'",
[  2] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:153:in `rbuf_fill'",
[  3] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:134:in `readuntil'",
[  4] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:144:in `readline'",
[  5] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http/response.rb:39:in `read_status_line'",
[  6] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http/response.rb:28:in `read_new'",
[  7] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1408:in `block in transport_request'",
[  8] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1405:in `catch'",
[  9] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1405:in `transport_request'",
[ 10] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1378:in `request'",
[ 11] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1371:in `block in request'",
[ 12] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:853:in `start'",
[ 13] "/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/net/http.rb:1369:in `request'",
[ 14] "/app/lib/api_helpers/connect.rb:10:in `call'",

OpenSSL Version on Heroku

OpenSSL 0.9.8k 25 Mar 2009

This error is not happening everytime the request, its happening rarely. I have tried replicating the same request with the same request parameters and response via Rails console, this issue doesn't seem to happen.

Please help.

Thanks

aBadAssCowboy
  • 2,440
  • 2
  • 23
  • 38
  • I have the feeling this could be more of a server error then local. Are you owning the server where you post the data? – Marc-Alexandre Bérubé Jul 11 '14 at 14:44
  • 1
    possible duplicate of ['EOFError: end of file reached' on HEROKU while posting UTF-8 via SSL](http://stackoverflow.com/questions/12387645/eoferror-end-of-file-reached-on-heroku-while-posting-utf-8-via-ssl) – Mike Campbell Jul 11 '14 at 14:51
  • @Marc-AlexandreBérubé This is on heroku. If there any configuration tweaking that I should be doing.? If you can tell me, I shall try doing. – aBadAssCowboy Jul 11 '14 at 15:07

0 Answers0