Project

General

Profile

Actions

Bug #19609

open

net/http ignores open_timeout, read_timeout on Windows

Added by inversion (Yura Babak) about 1 year ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]
[ruby-core:113302]

Description

This small sample works fine on Linux (it takes 2 seconds to finish) but on Windows, it always fails with a timeout after some magical 21 seconds.

require 'net/http'

uri = URI 'http://1.2.3.4'
http = Net::HTTP::new(uri.host, uri.port)
http.open_timeout = 2
http.read_timeout = 2

time_start = Time.now
begin
	response = http.get uri
rescue Exception
	puts $!.inspect
end
time_total = Time.now - time_start

puts time_total

Strange that I have installed different versions and the results are not consistent:

ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]:

#<Net::OpenTimeout: Failed to open TCP connection to 1.2.3.4:80 (execution expired)>
21.0494375

ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]:

#<Net::OpenTimeout: Failed to open TCP connection to 1.2.3.4:80 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - user specified timeout)>
2.0190419   # — works as expected

ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x64-mingw32]:

#<Net::OpenTimeout: execution expired>
21.0423962

No data to display

Actions

Also available in: Atom PDF

Like1