Closed jericopulvera closed 4 years ago
I apologize for the late reply. To be perfectly honest, I don't have a lot of experience with communicating errors via websockets, but my understanding is that if you want to trigger the onerror method of the websocket, the server will need close the connection with an 'abnormal' status code. See here.
Regarding your intended use-case, this looks like a promising lead. My gut tells me that you should not be handling authentication on the sendMessage action, but instead during the initial handshake.
I will leave this open for the time-being in case someone else might be more helpful.
Currently, we decided to use HTTP to handle sending messages as for our use case the user should receive messages when not authenticated, and by authenticating they'll be able to send messages.
Hi,
I'm trying to validate a JWT token in the server side and when returning a 401 response how do I handle it at the frontend?
What I've tried so far.
Did not log the error.