Help debugging IPv6 latency on Ruby Windows
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 148
- Fork
- 95
- Merge medio
- 10h 54m
- PR unite (30g)
- 4
Descrizione
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>
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con lo script di riproduzione fornito su Windows usando Ruby 3.0 e 3.1, confrontando Net::HTTP, Socket.tcp e TCPSocket.open per destinazioni IPv6 e IPv4. Traccia il percorso della connessione intorno alla modifica di Socket.tcp e confrontalo con il report collegato di rubyinstaller2; il lavoro è concluso quando la causa specifica di Windows o il successivo confine del debug sono documentati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- ruby
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100