From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS,WEIRD_PORT shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 7052D20248 for ; Thu, 21 Mar 2019 16:24:17 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id DF37F121948; Fri, 22 Mar 2019 01:24:11 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id D674D1218BA for ; Fri, 22 Mar 2019 01:24:09 +0900 (JST) Received: by filter0093p3iad2.sendgrid.net with SMTP id filter0093p3iad2-29374-5C93BAA7-43 2019-03-21 16:24:07.937367077 +0000 UTC m=+250239.310811668 Received: from herokuapp.com (unknown [3.88.45.208]) by ismtpd0030p1iad2.sendgrid.net (SG) with ESMTP id AfZ_tn26QESarkvvom-avg for ; Thu, 21 Mar 2019 16:24:08.022 +0000 (UTC) Date: Thu, 21 Mar 2019 16:24:08 +0000 (UTC) From: aditya.prakash132@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67401 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15628 X-Redmine-Issue-Author: sonalkr132 X-Redmine-Sender: sonalkr132 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?zpx+3gEWk8bh734em0IpkpLeu4z66U1xMZiMUBPiTuT7O7GLf73LYPnfRpTVtW?= =?us-ascii?Q?Y2jWlYMCM4I7P8JlLgEk9+17ZdLGMoCtgO=2F3KiC?= =?us-ascii?Q?Ezap=2Fs5GfcUFiACILl3zsJa73QNy1SojWsc2vEH?= =?us-ascii?Q?k3NsjAeGscOuAyqN0NcKFaHXcC5qlU4M7BnL6Bw?= =?us-ascii?Q?OY27MmNH6id9u45WYkJCA9S0ULG4F+5QuTw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 91915 Subject: [ruby-core:91915] [Ruby trunk Feature#15628] init_inetsock_internal should fallback to IPv4 if IPv6 is unreachable X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15628 has been updated by sonalkr132 (Aditya Prakash). > Net:HTTP with timeout (Net::OpenTimeout) after after 60 seconds I meant "Net:HTTP will timeout (Net::OpenTimeout) after 60 seconds". Any suggestion on fixing this would very helpful ![](https://gist.github.com/sonalkr132/debcab857485405e9a1117a62d5d1fd7/raw/caed6188620279f6a930a4058dba0def8153f5a9/download%2520(2).png). So far I have tried using `Socket.tcp(addr.ip_address, serv).close` to preemptively check if resolved addresses are reachable. It works but it is very inefficient. Besides the brute steps explained above, in the wild, this only affects host which have an IPv6 address but their IPv6 route to our CDN is broken. Personal home networks which generally have only IPv4 connectivity seamlessly use the IPv4 address to start the connection (without the need for a fallback). ---------------------------------------- Feature #15628: init_inetsock_internal should fallback to IPv4 if IPv6 is unreachable https://bugs.ruby-lang.org/issues/15628#change-77245 * Author: sonalkr132 (Aditya Prakash) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Hi, This is not really bug but more of a missing feature. Let me layout steps to reproduce what I am trying to achieve: * Add local entries for `example.com` ``` $ echo "::1 example.com www.example.com 127.0.0.1 example.com www.example.com" | sudo tee --append /etc/hosts ``` * Add rule to `DROP` ipv6 packets: `sudo ip6tables -P INPUT DROP` * Start a server: `ruby -rwebrick -e 'WEBrick::HTTPServer.new(Port: 8000).start'` * Making request using Net:HTTP with timeout (`Net::OpenTimeout`) after after 60 seconds: `ruby -rnet/http -e "Net::HTTP.get(URI('http://example.com:8000'))"` As far as I understand, [init_inetsock_internal](https://github.com/ruby/ruby/blob/4444025d16ae1a586eee6a0ac9bdd09e33833f3c/ext/socket/ipsocket.c#L42) needs to fallback to ipv4 for Net::HTTP.get to work. IPv6 route being broke is expected and hence, [RFC8305](https://tools.ietf.org/html/rfc8305) recommends fallback to IPv4. Support for IPv6 fallback is spotty across languages and http clients, for example, [golang supports it](https://github.com/golang/go/blob/master/src/net/dial.go#L47) but python doesn't, making request with `curl` works but `wget` hangs. -- https://bugs.ruby-lang.org/