You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How would you properly close a websocket connection? Basically what I am trying to do is check if correct query string parameters are not present then I close the connection.
Here's what I am trying to do right now.
app.ws.use(route.get('/ws', (ctx) => {
const { foo, bar } = ctx.query
if (!foo && !bar) {
ctx.websocket.close(1000, 'Wrong or missing parameters')
ctx.websocket.terminate()
return
}
}))
I am not really sure if this is correct because I keep on getting socket hang up messages and if I remove the return everything after the if statement still gets executed. I also tried using onclose event on the client but it never triggers.
The text was updated successfully, but these errors were encountered:
How would you properly close a websocket connection? Basically what I am trying to do is check if correct query string parameters are not present then I close the connection.
Here's what I am trying to do right now.
I am not really sure if this is correct because I keep on getting
socket hang up
messages and if I remove thereturn
everything after the if statement still gets executed. I also tried usingonclose
event on the client but it never triggers.The text was updated successfully, but these errors were encountered: