[ruby-core:120787] [Ruby master Bug#21088] TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts

Issue #21088 has been reported by dmlary (David Lary). ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088 * Author: dmlary (David Lary) * Status: Open * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/

Issue #21088 has been updated by alanwu (Alan Wu). This might be related to HEv2(#20108). Try testing with `Socket.tcp_fast_fallback = false`. ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111657 * Author: dmlary (David Lary) * Status: Open * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/

Issue #21088 has been updated by dmlary (David Lary). Setting `Socket.tcp_fast_fallback = false` does fix the issue. I get `Errno::ECONNREFUSED` in that case. ``` [1] pry(main)> require "socket" => true [2] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) from (pry):2:in 'TCPSocket#initialize' [3] pry(main)> Socket.tcp_fast_fallback = false => false [4] pry(main)> TCPSocket.new("test_system", 12345) Errno::ECONNREFUSED: Connection refused - connect(2) for "isr4" port 12345 (Errno::ECONNREFUSED) from (pry):4:in 'TCPSocket#initialize' ``` ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111677 * Author: dmlary (David Lary) * Status: Open * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/

Issue #21088 has been updated by midnight (Sarun R). This feature was merged a few months ago (#20782) by @shioimm, with a [non-trivial state machine implementation](https://gist.github.com/shioimm/fbb09f103caf0812137c5c67ffa14eb6). I'm pretty sure this is a missing edge case. ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111691 * Author: dmlary (David Lary) * Status: Open * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/

Issue #21088 has been updated by shioimm (Misaki Shioi). Thank you for reporting. I am aware of this issue and am working on resolving it. ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111694 * Author: dmlary (David Lary) * Status: Open * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/

Issue #21088 has been updated by hsbt (Hiroshi SHIBATA). Status changed from Open to Assigned Assignee set to shioimm (Misaki Shioi) ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111702 * Author: dmlary (David Lary) * Status: Assigned * Assignee: shioimm (Misaki Shioi) * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/

Issue #21088 has been updated by shioimm (Misaki Shioi). Status changed from Assigned to Closed @dmlary Unfortunately, I was unable to reproduce the issue you reported. However, I believe I have fixed the code that was likely causing the problem in this change. https://github.com/ruby/ruby/pull/12678 It should be resolved in the next Ruby version. If the issue still occurs, please let me know. Thank you very much for your report. ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111749 * Author: dmlary (David Lary) * Status: Closed * Assignee: shioimm (Misaki Shioi) * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/

Issue #21088 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED I think the changeset is worth to backport to ruby_3_4. ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111750 * Author: dmlary (David Lary) * Status: Closed * Assignee: shioimm (Misaki Shioi) * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/

Issue #21088 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONE ruby_3_4 commit:319c3c70385a63aaea3c1a68a79c70cfd533c6b6 merged revision(s) commit:1683dadb19876f0a64589bdbbcf6fff8143f78ff. ---------------------------------------- Bug #21088: TCPSocket.new raises Socket::ResolutionError instead of Errno::ECONNREFUSED for hosts defined in /etc/hosts https://bugs.ruby-lang.org/issues/21088#change-111936 * Author: dmlary (David Lary) * Status: Closed * Assignee: shioimm (Misaki Shioi) * ruby -v: 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-linux] * Backport: 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONE ---------------------------------------- `TCPSocket.new` raises `Socket::ResolutionError` when the connection is refused for hosts defined in /etc/hosts. It should raise `Errno::ECONNREFUSED`. ```ruby [6] pry(main)> TCPSocket.new("test_system", 22) => #<TCPSocket:fd 8, AF_INET, 10.1.1.1, 51690> [7] pry(main)> TCPSocket.new("test_system", 12345) Socket::ResolutionError: getaddrinfo(3): No address associated with hostname (Socket::ResolutionError) [14] pry(main)> ::Socket.getaddrinfo("test_system", nil) => [["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 1 (0x1), 6 (0x6)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 2 (0x2), 17 (0x11)], ["AF_INET", 0, "10.1.1.204", "10.1.1.204", 2 (0x2), 3 (0x3), 0]] ``` I've confirmed with tcpdump that the local system is sending the SYN to the remote host, and it is getting RST back. This was not a problem in 3.3.0. This does not happen when using `localhost` This does not happen for hosts resolvable via DNS. This is not the same as #20172 as this is a consistent failure and the fix for that was merged almost a year ago. -- https://bugs.ruby-lang.org/
participants (7)
-
alanwu (Alan Wu)
-
dmlary (David Lary)
-
hsbt (Hiroshi SHIBATA)
-
k0kubun (Takashi Kokubun)
-
midnight (Sarun R)
-
nagachika (Tomoyuki Chikanaga)
-
shioimm (Misaki Shioi)