[rabbitmq-discuss] Reconnecting to the Web-Stomp plugin after a network disconnection.

Anton Sizov a.sysoff at gmail.com
Tue Jul 23 08:02:58 BST 2013


Hi
Probably you need to create new SockJS object (tcp connection) on 
disconnect. See line 16. I assume ws is TCP connection object. More info 
for SockJS you can find at https://github.com/sockjs/sockjs-client.
Try to move lines 16-22 to Connect() function.
Also, any debug messages on reconnect attempt are welcome. 

On Saturday, July 20, 2013 8:31:03 PM UTC+3, joshu... at hotmail.com wrote:
>
> Using references on http://jmesnil.net/stomp-websocket/doc/ and 
> http://www.rabbitmq.com/web-stomp.html, I managed to come out with my own 
> Web-Stomp js code that can connect and receive messages.  However, I'm 
> unable to reconnect in the event the connection to Web-Stomp server breaks.
>
> What I did is on on_connect_error, I did a client.disconnect, followed by 
> a client.connect.  The disconnect works but the connect fails.  
>
> Since I'm not able to find any code example that deals with reconnecting, 
> I took a look at sockjs groups but it appears to me that the code used for 
> sockjs is different from that of web-stomp plugin examples.
>
> Here's the full js code: Here is my full code: 
> http://pastebin.com/dtEBnzGP
>
>
>    1. function on_connect_error(error) {
>    2.   $('#output').append('Connection failed! Error:'+ error + "<br>");
>    3.     $('#output').append('Disconnecting....'  + "<br>");
>    4.  client.disconnect(function() {
>    5.     $('#output').append('Disconnected!' + "<br>");
>    6.   });
>    7.   $('#output').append('Reconnecting...' + "<br>");
>    8.   Connect();
>    9. }
>    
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130723/7e65a81a/attachment.htm>


More information about the rabbitmq-discuss mailing list