Help debugging IPv6 latency on Ruby Windows
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 148
- Forks
- 95
- Ø Merge
- 10 Std. 54 Min.
- Gemergte PRs (30 T.)
- 4
Beschreibung
I am experiencing this issue on a Windows machine. Original issue filed with Windows Ruby installer: https://github.com/oneclick/rubyinstaller2/issues/264
It seems that the change from TcpSocket to Socket (https://github.com/ruby/net-http/pull/10) released in Ruby 3.1 is now causing timeout latency for me when accessing IPv6 sites using Net::HTTP. Socket.tcp waits 60 sec attempting connect to IPv6, times out, then immediately connects to IPv4. TCPSocket.open does not have this issue.
TCPSocket.open("google.com", 80, nil, nil) # fast
Socket.tcp("google.com", 80, nil, nil, connect_timeout: 60) # times out after 60 sec on IPv6, then falls back to IPv4
TCPSocket.open is fast on both Ruby 3.0 and 3.1, while Socket.tcp is slow on both Ruby 3.0 and 3.1. However, since Net::HTTP switched to Socket in 3.1 it has the end-result of making Net::HTTP slow overall.
The issue may be Windows-specific, since I do not see when using Linux via WSL Ubuntu on the same Windows machine. There's a lot more details in the rubyinstaller2 issue, however, I'm wondering if someone can provide some insight on how to debug this further.
Script to reproduce issue:
require 'uri'
require 'net/http'
require 'openssl'
module HTTPS_IPv4_IPv6
class << self
def run(uri_str)
uri = URI(uri_str)
puts uri_str
t_st = Process.clock_gettime(Process::CLOCK_MONOTONIC)
Net::HTTP.start(uri.host, uri.port, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_PEER) do |http|
req = Net::HTTP::Get.new uri.request_uri
resp = http.request req
case resp
when Net::HTTPSuccess
body = resp.body
t_end = Process.clock_gettime(Process::CLOCK_MONOTONIC)
puts "body bytesize #{body.bytesize}"
puts format("response time %6.3f sec", t_end - t_st)
puts http.instance_variable_get(:@socket).io.to_io.remote_address.inspect, ''
when Net::HTTPRedirection
puts "#{resp.class}\n Redirect: #{resp['location']}"
run resp['location']
else
puts resp.class
end
end
end
end
end
puts '', RUBY_DESCRIPTION, ''
HTTPS_IPv4_IPv6.run 'https://www.google.com'
HTTPS_IPv4_IPv6.run 'https://global.jd.com'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
https://www.google.com
body bytesize 15110
response time 2.390 sec
#<Addrinfo: 142.251.42.196:443 TCP>
https://global.jd.com -- IPv4 only
body bytesize 20592
response time 0.633 sec
#<Addrinfo: 14.0.43.163:443 TCP>
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem bereitgestellten Reproduktionsskript unter Windows mit Ruby 3.0 und 3.1 und vergleiche Net::HTTP, Socket.tcp und TCPSocket.open für IPv6- und IPv4-Ziele. Verfolge den Verbindungsweg rund um die Änderung an Socket.tcp und vergleiche ihn mit dem verlinkten Bericht von rubyinstaller2; abgeschlossen ist die Untersuchung, wenn die Windows-spezifische Ursache oder die nächste Debugging-Grenze dokumentiert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ruby
- Bereich
- networking
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100