I have a device that connects to a server (written in Scala and Play) through WebSocket. When I turn off the device, the connection remains open. Is there a way to set a WebSocket connection keepalive timeout in Play framework to check if the client endpoint is off. Thanks.
Came across this problem a while ago. The solution we settled on was to implement a heartbeat (ping-pong) strategy.
So every 5 seconds for instance, send a ping
message and wait for the pong
reply, then kill the connection (an Actor in our use case) to the subscriber if no message is received.