You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now it's not possible to configure the timeout defaults of the Net::HTTP clients (and possibly EM::HTTPClient).
Here are the defaults on Net::HTTP:
keep_alive_timeout = 2
# Depends on system settings. Usually 240 seconds on Linux.
open_timeout = nil
read_timeout = 60
continue_timeout = nil
ssl_timeout = nil
In the context of a webapp you usually want to lower these numbers to stay below a ~5 second threshold and then return an error message to the user if the connection or response didn't happen. The webapp usually has fast connectivity so we don't need to be so forgiving during the connection. Issues are more related to downtime or equipment failure and giving it more time won't generally help. Heroku also disconnects the customer from the webapp after 30 seconds so in that case you also want to send a meaningful reply to the customer instead of the default heroku 500 message.
Thanks for digging into this Jonas - you're completely right the timeout should be configurable. We're planning to switch from Net::HTTP for a variety of reasons, but I'll keep this in mind.
@zimbatm would be great if you could take the new version for a spin - you can easily set all the timeouts via Pusher.timeout = 5, or set the individual timeouts if you like (see client.rb). The keepalive change should make a big difference too :)
Right now it's not possible to configure the timeout defaults of the Net::HTTP clients (and possibly EM::HTTPClient).
Here are the defaults on Net::HTTP:
In the context of a webapp you usually want to lower these numbers to stay below a ~5 second threshold and then return an error message to the user if the connection or response didn't happen. The webapp usually has fast connectivity so we don't need to be so forgiving during the connection. Issues are more related to downtime or equipment failure and giving it more time won't generally help. Heroku also disconnects the customer from the webapp after 30 seconds so in that case you also want to send a meaningful reply to the customer instead of the default heroku 500 message.
I don't have the time right now to propose a patch so until them I'm going to use the following monkey-patch. If you add a setting to these defaults make sure to catch the "Net::OpenTimeout" exception in https://github.com/pusher/pusher-gem/blob/master/lib/pusher/request.rb#L40
Cheers !
The text was updated successfully, but these errors were encountered: