Don't allow Net::HTTP to hang forever
Net::HTTP has default infinite timeout for opening connection, which, when other side does not open connection fully, nor rejects connecting, results in infinite thread hang without any reporting into log. Fix it by explicitly making all timeouts finite (set to default Net::HTTP's read_timeout 60 seconds). /cc @klaus
Showing
... | @@ -65,7 +65,15 @@ class WendelinClient | ... | @@ -65,7 +65,15 @@ class WendelinClient |
:use_ssl => (uri.scheme == 'https'), | :use_ssl => (uri.scheme == 'https'), | ||
# NOTE = "do not check server cert" | # NOTE = "do not check server cert" | ||
# TODO move this out to conf parameters | # TODO move this out to conf parameters | ||
:verify_mode => OpenSSL::SSL::VERIFY_NONE | :verify_mode => OpenSSL::SSL::VERIFY_NONE, | ||
|
|||
# Net::HTTP default open timeout is infinity, which results | |||
# in thread hang forever if other side does not fully | |||
# establish connection. Default read_timeout is 60 seconds. | |||
# We go safe way and make sure all timeouts are defined. | |||
:ssl_timeout => 60, | |||
:open_timeout => 60, | |||
:read_timeout => 60, | |||
) do |http| | ) do |http| | ||
http.request(req) | http.request(req) | ||
end | end | ||
... | ... |