-
-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Hi there,
Just ran into this hairy issue that took me a while to narrow down while using tinyws in Kitten with Polka:
https://codeberg.org/kitten/app/issues/113
Basically, the WebSocket routes on my https server were timing out after 120 seconds (the default timeout for Node https servers) with a 1006 error. The upgrade was happening correctly and the socket was otherwise fine. If I listened to the clientError
event on the server, I could work around the issue and prevent the socket from closing but I wanted to get to the bottom of it and fix it properly (of course).
The problem is that it doesn’t seem to happen in a very basic reproduction attempt using tinyws or even tinyws + polka.
However, through lots of trial an error, I was able to narrow down the issue to how tinyws is setting the upgrade header.
TL;DR: Setting Buffer.alloc(0)
instead of actually using a copy of the header that it receives. Mostly because, since it doesn’t handle the upgrade event itself, it doesn’t have access to the actual header.
So I’m not sure if you can fix this without essentially transforming tinyws into express-websocket but I thought I’d open an issue and document it here too.
My initial implementation is a mix of tinyws and express-websocket. Please feel free to copy/adapt it if you like:
https://codeberg.org/kitten/app/src/branch/main/src/Server.js#L50