How to prevent WebSocket connection closing #990
Replies: 1 comment
-
Malformed JSON will cause an exception to be thrown from the The issue with this though, is if you can't deserialize a JSON-RPC message, you can't respond to it either to notify the sender that an error occurred. That can be worse than disconnecting, because at least in disconnecting, the sender knows something went very wrong. But the server simply dropping an invalid message without an error could leave the client hanging forever. There doesn't seem to be any valid cause for malformed JSON in production environments, so disconnecting seems like the right thing, IMO. And in development environments... I'm not sure what system can't reliably send valid JSON-RPC messages either, unless you're hand-typing them in, in which case disconnection seems easy enough to recover from. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a middleware, checking for websocket request,
Everything works, the problem is when i send a
malformed json
it closes the connection, can i prevent closing ?Thanks
Beta Was this translation helpful? Give feedback.
All reactions