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
I am unable to close a socket from the message handler
Steps to Reproduce
require "kemal"
ws "/" do |sock, context|
sock.on_message do |message|
puts message
sock.close HTTP::WebSocket::CloseCode::NormalClosure
end
sock.on_close do
puts "Waah"
end
end
Kemal.run
Expected behavior:
It should close the websocket after a message is recieved
Actual behavior:
The websocket stays open and can continue sending messages
on_close is only triggerred if a websocket connection is closed from the othe side. Since your server is the one that closed it. The on_close handler will never get triggerred.
If the client were to close the connection. on_close would be triggerred on the server side.
To clarify: on_close listens for a WebSocket close event. This is a specific event that must be explicitly sent from the other end. It's not implicit when for example the underlying connection closes.
Description
I am unable to close a socket from the message handler
Steps to Reproduce
Expected behavior:
It should close the websocket after a message is recieved
Actual behavior:
The websocket stays open and can continue sending messages
Reproduces how often:
continually
Versions
The text was updated successfully, but these errors were encountered: