Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework: WebSocket connection timeout

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.

like image 653
Mattia Micomonaco Avatar asked Aug 28 '15 16:08

Mattia Micomonaco


1 Answers

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.

like image 69
airudah Avatar answered Sep 27 '22 22:09

airudah