[rabbitmq-discuss] Reconnecting to the Web-Stomp plugin after a network disconnection.
joshua__lim at hotmail.com
joshua__lim at hotmail.com
Sat Jul 20 18:31:03 BST 2013
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/20130720/75b2e1d7/attachment.htm>
More information about the rabbitmq-discuss
mailing list