[SOLVED] Effect HTTP Server Websocket Upgrade
Hey everyone 
I am trying to get a combined HTTP Server (using the Effect HTTP Server from Platform) and Websocket server that uses both the same Node HTTP Server port.
Very similar to @whatplan s workshop project (https://github.com/ethanniser/effect-workshop/blob/0e1d4b7c887fd5c515d332421648271976509ea1/src/part3-webserver/breakpoints/99-effect-client/server/ws.ts#L230)
Which is a good project to reproduce my issue:
When installing and running the server with
When running with
The error vanishes when the linked
It also vanishes when I remove the HTTPLive Router implementation from the merged layer.
For me it feels like that on
I've tried to manually upgrade the Request in the Effect HTTP Router like this:
But this yields a different error:
I am trying to get a combined HTTP Server (using the Effect HTTP Server from Platform) and Websocket server that uses both the same Node HTTP Server port.
Very similar to @whatplan s workshop project (https://github.com/ethanniser/effect-workshop/blob/0e1d4b7c887fd5c515d332421648271976509ea1/src/part3-webserver/breakpoints/99-effect-client/server/ws.ts#L230)
Which is a good project to reproduce my issue:
When installing and running the server with
bun it works out of the box and I can connect Postman via WS and send messages.When running with
tsx or ts-node im getting the following Error message in Postman:Error: Invalid WebSocket frame: RSV1 must be clearThe error vanishes when the linked
WebsocketServer is created with option {port: 3001} instead of the node.js HTTP server passed in directly as seen in the workshop files.It also vanishes when I remove the HTTPLive Router implementation from the merged layer.
For me it feels like that on
node the Effect HTTP Server is not behaving the same way as on bun although the NodeRuntime is used and not BunRuntime.I've tried to manually upgrade the Request in the Effect HTTP Router like this:
But this yields a different error:
Error: Unexpected server response: 204 (also when providing status: 101) it is the same error but with the different status code.GitHub
Contribute to ethanniser/effect-workshop development by creating an account on GitHub.
