Comments (3)
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.
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.
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)
- version 1.43.1 downloaded from 1.43.0 assets ? HOT 1
- `trailers`/`Deno.trailers` support for `Deno.serve` and `fetch`
- fs.statSync gives different error in Deno vs Node for bad file path on Windows HOT 1
- fmt_watch_without_args_test is flaky
- Map npm workspace packages to JSR specifiers on publish if npm package in workspace is a jsr package?
- Use "URL.canParse()" rather than "URL.parse()" HOT 2
- wrong tag with 1.43.1 HOT 5
- node process.env does not delete values
- LSP Errors in main HOT 4
- HTTPS import of jsr package with dependencies makes deno panic
- deno publish: linter detect slow types on non-public API if `keyof typeof` is used on unexported member HOT 4
- feat: `deno serve` pick random free port
- Bug: `deno serve --host localhost` prints invalid URL HOT 7
- Bug: `deno serve` errors on fetch callback with no arguments
- `cargo r --features __runtime_js_sources test` fails HOT 1
- Using DuckDB with Deno HOT 6
- `isUtf8` and `isAscii` do not exist in `node:buffer`
- deno publish requires base classes to be exported or else "Failed ensuring public API type output is valid." HOT 3
- Bug: LSP unable to cache npm package
- Internal: Add "tests" to spec tests in addition to "steps" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno.