From: radarek via ruby-core Date: 2025-02-24T00:12:32+00:00 Subject: [ruby-core:121147] [Ruby master Bug#21104] Net::HTTP connections failing in Ruby >= 3.4.0 on macOS with Happy Eyeballs enabled Issue #21104 has been updated by radarek (Rados��aw Bu��at). shioimm (Misaki Shioi) wrote in #note-5: > If possible, could you run these and let me know the results? > > - Check if you can connect to `http://example.com/` (not https) using `Net::HTTP`. It fails for ruby 3.4.2: ``` $ RBENV_VERSION=3.4.2 ruby -v -rnet/http -e 'puts Net::HTTP.get(URI("http://example.com/"))' ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [arm64-darwin24] :63:in 'IO#read_nonblock': Connection reset by peer (Errno::ECONNRESET) from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/protocol.rb:218:in 'Net::BufferedIO#rbuf_fill' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/protocol.rb:199:in 'Net::BufferedIO#readuntil' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/protocol.rb:209:in 'Net::BufferedIO#readline' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http/response.rb:158:in 'Net::HTTPResponse.read_status_line' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http/response.rb:147:in 'Net::HTTPResponse.read_new' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:2414:in 'block in Net::HTTP#transport_request' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:2405:in 'Kernel#catch' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:2405:in 'Net::HTTP#transport_request' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:2378:in 'Net::HTTP#request' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:2249:in 'Net::HTTP#request_get' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:826:in 'block in Net::HTTP.get_response' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:1626:in 'Net::HTTP#start' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:1064:in 'Net::HTTP.start' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:824:in 'Net::HTTP.get_response' from /Users/radarek/.rbenv/versions/3.4.2/lib/ruby/3.4.0/net/http.rb:805:in 'Net::HTTP.get' from -e:1:in '
' ``` Doing it with pure socket also fails: ```ruby require "socket" s = TCPSocket.open("example.com", 80) s.write "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n" puts s.gets(nil) s.close ``` Running this program I get: ``` $ RBENV_VERSION=3.4.2 ruby -v socket.rb ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [arm64-darwin24] socket.rb:4:in 'IO#gets': Connection reset by peer (Errno::ECONNRESET) from socket.rb:4:in '
' ``` > - This will help determine whether connections to port 80 behave the same way as connections to port 443. If the connection to port 80 succeeds while port 443 fails, it may indicate that a firewall or similar mechanism is injecting RST into port 443 connections. From the previous experiment it looks like they behave the same so the problem is not specific to 443 port. > - Check whether IPv6 is enabled or disabled, and test `Net::HTTP` in both states to see if the results are the same. > - For example, if you are using Wi-Fi, you can check the IPv6 status with `networksetup -getinfo Wi-Fi`. This will help verify whether there is a hidden issue in the HEv2 implementation. I turned off ipv6 by executing `networksetup -setv6off Wi-Fi` (and verified with `networksetup -getinfo Wi-Fi`) but it didn't change previous outcomes. > - If you are using any network extension software on your Mac, disable it and check whether `Net::HTTP` behaves differently compared to when it is enabled. > - You can check the list of network extension software by running `systemextensionsctl list`. This will help determine whether any particular software is injecting RST. The only one extension which is listed is some OBS camera extension which is disabled: ``` systemextensionsctl list 1 extension(s) --- com.apple.system_extension.cmio (Go to 'System Settings > General > Login Items & Extensions > Camera Extensions' to modify these system extension(s)) enabled active teamID bundleID (version) name [state] * 2MMRE5MTB8 com.obsproject.obs-studio.mac-camera-extension (30.1.0/8254614054) com.obsproject.obs-studio.mac-camera-extension [activated disabled] ``` > - If you have another machine with Ruby 3.4 installed besides the Mac where the issue occurs, check whether the same problem happens on that machine. I have second Mac from company I work for, connected to the same network (but it runs software related to the network - zscaler, which I believe can intercept network connections) and there is no issue. > > I would appreciate any information you can provide. I'll be happy to provide any information which could be useful to fix this bug. ---------------------------------------- Bug #21104: Net::HTTP connections failing in Ruby >= 3.4.0 on macOS with Happy Eyeballs enabled https://bugs.ruby-lang.org/issues/21104#change-112077 * Author: mjt58 (Mike Thompson) * Status: Open * ruby -v: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- A project I work on recently upgraded Ruby to 3.4.1 from 3.3.5. Following the upgrade, and when running locally on my Mac, all attempts to connect to an external service within the project over http(s) fail. We use `mise` for managing development tool dependencies, including Ruby, and I am using macOS 15.3. For example running something as simple as: ``` require 'net/http' puts Net::HTTP.get(URI('https://bbc.co.uk')) ``` Will fail with the following stack trace: ``` /path/to/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/net/protocol.rb:46:in 'OpenSSL::SSL::SSLSocket#connect_nonblock': Connection reset by peer - SSL_connect (Errno::ECONNRESET) from /path/to/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/net/protocol.rb:46:in 'Net::Protocol#ssl_socket_connect' from /path/to/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/net/http.rb:1736:in 'Net::HTTP#connect' from /path/to/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/net/http.rb:1636:in 'Net::HTTP#do_start' from /path/to/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/net/http.rb:1625:in 'Net::HTTP#start' from /path/to/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/net/http.rb:1064:in 'Net::HTTP.start' from /path/to/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/net/http.rb:824:in 'Net::HTTP.get_response' from /path/to/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/net/http.rb:805:in 'Net::HTTP.get' from request.rb:2:in '
' ``` I tried different versions of Ruby and confirmed that the issue appears with 3.4.0. After reading the release notes for this version, I tried setting `RUBY_TCP_NO_FAST_FALLBACK=1` and this worked, allowing me to work around the problem. This issue has also been encountered by others, please see: https://github.com/rubygems/rubygems/issues/8390 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/