-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception handling in Websocket #6173
Comments
@aeolus You are right there isn't error handling. Here is the PR for that feature. 218c349#diff-464984cc0483db2f695a4c90c82c0d69 You can pass your wssAdapter into your parse server config. Here is the adapter we use internally.
The question now is what is causing your issue the server or the client? Edit: What version of node are you running? Maybe updating it will fix your issue. |
@dplewis thank you very much for your reply. We are currently running parse-server 3.1.3 and try to move to 3.9.0 (need to update a few places but that's another story). We run parse-server with Express, it is a little hard since I did not find a good way to troubleshoot websocket server exception or even handle/catch the error itself. With the newer version of parse-server, at least I have the chance to add an on error handler and might just log it instead of rethrowing it to the app. Base on the current info we have, it is hard to figure out the root cause. It might be related to load (concurrency) on the ws lib, but on the other side, I saw the same problem when the load is not very high. Just googling the error message does not give me much help either. If anybody has a theory, I am all ears. |
If you have a web client, you can inspect the web socket connection and view the packets / frames. Maybe you will find something. That’s all I got, sorry I couldn’t be more helpful |
Closes: #6173 Prevents an unhandled server rejection. Includes an example for LiveQuery test and closing the proper connections. Improve live query monitoring
* Improve WebSocketServer Error Handling Closes: #6173 Prevents an unhandled server rejection. Includes an example for LiveQuery test and closing the proper connections. Improve live query monitoring * fix tests
I got the same issue. And dplewis 's PR looks be applied in v3.10.0. Thanks. |
@dplewis parse-server: 3.10.0 .../node_modules/parse-server/lib/ParseServer.js:229
throw err;
^
RangeError: Invalid WebSocket frame: invalid payload length 126
at Receiver.getInfo (.../node_modules/parse-server/node_modules/ws/lib/receiver.js:213:16)
at Receiver.startLoop (.../node_modules/parse-server/node_modules/ws/lib/receiver.js:127:22)
at Receiver._write (.../node_modules/parse-server/node_modules/ws/lib/receiver.js:74:10)
at doWrite (_stream_writable.js:415:12)
at writeOrBuffer (_stream_writable.js:399:5)
at Receiver.Writable.write (_stream_writable.js:299:11)
at Socket.socketOnData (.../node_modules/parse-server/node_modules/ws/lib/websocket.js:875:35)
at Socket.emit (events.js:198:13)
at Socket.EventEmitter.emit (domain.js:448:20)
at addChunk (_stream_readable.js:288:12)
[ERROR] 16:23:14 RangeError: Invalid WebSocket frame: invalid payload length 126 |
@aeolus Did you got any idea? I have a same issue. |
* Improve WebSocketServer Error Handling Closes: parse-community#6173 Prevents an unhandled server rejection. Includes an example for LiveQuery test and closing the proper connections. Improve live query monitoring * fix tests
* Websocket: unhandle rejection Closes: parse-community#6413, parse-community#6173 Prevent crashing on websocket error. Bonus points to anybody who can post a specific payload that the client sends that returns an error. * log the socket * fix tests * fix payload reference link
Hi, recently in our production environment, we seen exceptions from WebSocket (live query).
The explicit exception is from ws lib:
RangeError: Invalid WebSocket frame: invalid payload length 126
which caused our application to crash because apparently this has been escalated into an uncaughtException for the parse application.
Right now we have no idea about the root cause due to missing logging in the wssocket communication and also don't know the proper fix for it.
By looking at the latest version of parse-server, it seems to be possible to customize the wssocket adapter to explicitly handle errors/incoming traffic etc. However, this adaptor doesn't seem to be available to the public or maybe I just missed something here.
Is there any good suggestion for us to prevent the app from crashing? Thanks
The text was updated successfully, but these errors were encountered: