Git Product home page Git Product logo

Comments (3)

mmastrac avatar mmastrac commented on May 13, 2024 1

This might be a useful thing for us to do for all outgoing connections, but it's definitely more of an infrastructure bug on that server's end.

This would apply to Deno.connect, Deno.connectTls and the WebSocket APIs.

from deno.

NfNitLoop avatar NfNitLoop commented on May 13, 2024

One other difference I noticed (by enabling debug logging in nginx) is that Chrome sends more headers for a socket connection than Deno does.

Deno:

2024/04/26 23:40:56 [debug] 15476#15476: *10422 http process request header line
2024/04/26 23:40:56 [debug] 15476#15476: *10422 http header: "host: nfnitloop.com"
2024/04/26 23:40:56 [debug] 15476#15476: *10422 http header: "upgrade: websocket"
2024/04/26 23:40:56 [debug] 15476#15476: *10422 http header: "connection: Upgrade"
2024/04/26 23:40:56 [debug] 15476#15476: *10422 http header: "sec-websocket-key: W0SiuJe06vzA/KP0pRNfJQ=="
2024/04/26 23:40:56 [debug] 15476#15476: *10422 http header: "user-agent: Deno/1.42.4"
2024/04/26 23:40:56 [debug] 15476#15476: *10422 http header: "sec-websocket-version: 13"
2024/04/26 23:40:56 [debug] 15476#15476: *10422 http header done

Chrome:

2024/04/26 23:41:58 [debug] 15476#15476: *10438 http process request header line
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Host: nfnitloop.com"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Connection: Upgrade"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Pragma: no-cache"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Cache-Control: no-cache"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Accept-Language: en-US,en;q=0.6"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Upgrade: websocket"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Origin: https://www.typescriptlang.org"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Sec-WebSocket-Version: 13"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Accept-Encoding: gzip, deflate, br, zstd"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Sec-WebSocket-Key: RuM8MQoo59PCagkMqDo3sA=="
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header: "Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits"
2024/04/26 23:41:58 [debug] 15476#15476: *10438 http header done

Again, I apologize, I'm not sure whether those are relevant. Still trying to debug here.

I will say, if the timing of the debug output from nginx is to be trusted, it really looks like Deno just sits there doing nothing for 70+ seconds before making the connection. Immediately, once we get the first message about the connection in nginx:

2024/04/26 23:40:56 [debug] 15476#15476: *10422 SSL ALPN supported by client: http/1.1

the entire web socket upgrade process completes within the 1-second resolution of logs:

2024/04/26 23:40:56 [debug] 15476#15476: *10422 close http connection: 22
2024/04/26 23:40:56 [debug] 15476#15476: *10422 SSL_shutdown: 1
2024/04/26 23:40:56 [debug] 15476#15476: *10422 reusable connection: 0

from deno.

NfNitLoop avatar NfNitLoop commented on May 13, 2024

Found the issue:

My host, nfnitloop.com had an old/invalid IPv6 address in DNS.

Chrome's implementation simultaneously tries to open an IPv6 and and IPv4 connection, and continues with whichever responds first.

Deno's implementation seems to always try IPv6 first. Only after that times out (75 seconds?) does it fall back to IPv4.

So, yes, as far as my server was concerned, Deno was doing nothing for 70+ seconds before connecting.

Oddly, Deno's fetch() implementation does the same thing that Chrome does, and tries both IPv6 and 4 simultaneously. It might be good to do the same thing for WebSocket!

from deno.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.