Home Rails HTTP request raises `EOFError: end of file reached` after some time
Reply: 0

Rails HTTP request raises `EOFError: end of file reached` after some time

user2669
1#
user2669 Published in August 15, 2018, 5:36 am

I have two Rails apps that are communicating through HTTP.

The app that is supposed to receive requests takes a long time to respond. I expect that, so using my preferred request method (provided by the httparty gem) I increase the timeout and submit the request:

HTTParty.get("https://example.com", :timeout => 99999)

After approx. 2 minutes the error EOFError: end of file reached is raised by the requesting app, with the following stack trace:

from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/protocol.rb:153:in `read_nonblock'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/protocol.rb:144:in `readline'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http/response.rb:39:in `read_status_line'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http/response.rb:28:in `read_new'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:1414:in `block in transport_request'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:1411:in `catch'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:1411:in `transport_request'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:1384:in `request'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:1377:in `block in request'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:853:in `start'
from .rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:1375:in `request'
from .rvm/gems/ruby-2.2.2/gems/httparty-0.13.7/lib/httparty/request.rb:117:in `perform'
from .rvm/gems/ruby-2.2.2/gems/httparty-0.13.7/lib/httparty.rb:545:in `perform_request'
from .rvm/gems/ruby-2.2.2/gems/httparty-0.13.7/lib/httparty.rb:476:in `get'
from .rvm/gems/ruby-2.2.2/gems/httparty-0.13.7/lib/httparty.rb:583:in `get'
from (irb):14
from .rvm/gems/ruby-2.2.2/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from .rvm/gems/ruby-2.2.2/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from .rvm/gems/ruby-2.2.2/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from .rvm/gems/ruby-2.2.2/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from .rvm/gems/ruby-2.2.2/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'

But in the log of my receiving app I can see that the request is still being processed. So the requesing app must be raising the exception based on something else that a response.

Any idea how to avoid this?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.342524 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO