Question

I'm calling an external API over HTTP which will take more 30 seconds to provide a response. When I run it, although the API call completes successfully (the remote service does what it's supposed to do), my Ruby gets a timeout error before it receives the 'OK' response. I get this error:

/Users/chris/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/net/protocol.rb:158:in `rescue in rbuf_fill': Net::ReadTimeout (Net::ReadTimeout)

Is there a way I can give it more time so it can cleanly handle the response?

No correct solution

OTHER TIPS

http = Net::HTTP.new(@host, @port)
http.read_timeout = 500

Source: http://ruby-doc.org/stdlib-2.1.1/libdoc/net/http/rdoc/Net/HTTP.html#method-i-read_timeout-3D

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top