rstoyanchev / spring-websocket-portfolio

740 stars 443 forks source link

Reconecting WebSocketStompClient #59

Closed cmadsen closed 9 years ago

cmadsen commented 9 years ago

How do I detect a lost connection and reconnect using a WebSocketStompClient?

Using SockJS I would do something like this:

            var reconnect = function() {
                setTimeout(initSockets, 10000);
            };

            var initSockets = function() {
                var socket = {};
                socket.client = new SockJS('http://....');
                ...
                socket.client.onclose = reconnect;
            }

Also, is it possible to get notified every time the WebSocketStompClient receives a heartbeat somehow?

cmadsen commented 9 years ago

This was caused by using tomcat-websocket 8.0.0-RC5 switching to 8.0.27 fixed it.