Help debugging IPv6 latency on Ruby Windows
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- ruby
- 领域
- networking
调研方向
在 Windows 上使用 Ruby 3.0 和 3.1,从提供的复现脚本开始,比较面向 IPv6 和 IPv4 目标的 Net::HTTP、Socket.tcp 和 TCPSocket.open。跟踪 Socket.tcp 更改附近的连接路径,并与链接的 rubyinstaller2 报告进行比较;当 Windows 特定原因或下一个调试边界被记录后,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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>
- 主要语言
- Ruby
- 星标
- 148
- 派生
- 95
- 平均合并
- 10 小时 54 分钟
- 30 天内合并 PR
- 4
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/net-http 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 83/100
-
难度 5/5 一周以上 新手友好度 38/100
-
难度 4/5 3-5 天 新手友好度 55/100
-
难度 4/5 3-5 天 新手友好度 55/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
riscv/riscv-unified-db#2626 ·
-
Component: GLib
难度 2/5 1-3 小时 新手友好度 70/100
-
ds-drift
难度 2/5 1-3 小时 新手友好度 70/100
we-promise/sure#3693 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
simp/pupmod-simp-simp#395 ·