deno-websocket
deno-websocket copied to clipboard
Crash: request is not acceptable in server
Hi and thanks for this library, it really ease things up.
I have detected that when you use WebSocketServer and go and try to establish an HTTP connection to the websocket port the server crashes and closes.
While I obviously don't expect the WS server to work properly when being contacted by the wrong protocol it should fail silently, or at least, allow the programmer to specify an error callback in case things like this occur.
I know that the error is indeed generated by Deno's std library ws. However I think if possible it should be handled here.
Steps to reproduce
-
deno run --allow-net https://deno.land/x/[email protected]/example/server.ts
- Open http://localhost:8080/
- Now the server has crashed
Thanks.
Thank you for your issue.
OK. I will support it.
Same issue here. It makes the app crashes.
error: Uncaught (in promise) Error: request is not acceptable
throw new Error("request is not acceptable");
^
at acceptWebSocket (https://deno.land/[email protected]/ws/mod.ts:453:9)
at WebSocketServer.connect (https://deno.land/x/[email protected]/lib/websocket.ts:35:28)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `sh run.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2021-06-20T16_17_35_643Z-debug.log
You can just do something like:
WebsocketServer.on("error", console.log)
That will catch all errors like this and just log them to console,
Just using native WebSockets. https://deno.com/blog/v1.12#server-side-websocket-support-in-native-http