Hi,
I'd like to talk about an issue bothering me for a long time. My web socket implementation started to hang after a while when I moved my application behind F5 load-balancer.
It turns out that, F5 somehow drops the web socket connection after a while. Probably there is a timeout value that drops inactive connections. Our F5 admins couldn't figure out the issue so I had to implement a workaround that basicly sends mock events even if there is no new server sent data.
My workaround is highlighted below:
On the server side:
// check the job result has new values to sent to the clients
if (coll.isNew()) {
responseList.add(PointDate);
responseList.add(point);
responseList.add(count);
StatefulModel.instance.event.publish(responseList);
}
else {
// sending mock data to keep connection alive
responseList.add(null);
StatefulModel.instance.event.publish(responseList);
}
On the client side:
ws = new WebSocket('@@{Total.getLatest}');
ws.onmessage = function(evt) {
var data = JSON.parse(evt.data);
if (data[0] != null) {
var date = data[0];
var point = data[1];
var count = data[2];
print("containerMax", count, point, date);
}
}
Note:
Here is a great article about web socket implementation with Play Framework 1.2.7:
http://playframework.wordpress.com/2011/04/25/websockets-in-play/
Bye...