Closed genuinefafa closed 8 years ago
This article propose to reconnect with the onclose function on the stompClient.
But, I don't find any information about this element in the official Stomp-Websocket-JS documentation (http://jmesnil.net/stomp-websocket/doc/).
The best implementation in AngularStompDK seems to add an attribute on configuration to define if we want to reconnect on close.
For other behaviour (for example, modify a controller value on close), we will need an other callback function define on the service invocation.
I will do some investigation as soon as possible (maybe this week-end), and I will let you know. Don't forge, you can do a PR if you want to help.
Thanks
Interesting. I was pretty sure that reconnect
behavior was part of the specification. You are right, it is not. However, the source code for the stomp-websocket does have that method.
I'm not a expert user of this tecnologies. That's why I am at the read article and do comments stage. :expressionless:
Do you think I can help? I'm more than ready to do that. Just point me in the right direction and I'll do my best. :metal:
You can help, you just have to test and check if a behavior can be associated with the onclose of Stomp. I'm building a little backend app to ease the testing of the lib (https://github.com/davinkevin/spring-websocket-disconnect) and I'm trying to add a custom behavior...
For the API modification, let me now what you prefer (just an element on config to auto-reconnect) or a special behavior for each call to ngStompProvider ?
I've modified the onclose callback of the StompClient (https://github.com/davinkevin/spring-websocket-disconnect/blob/master/src/main/resources/static/angularStompDK.js#L198), it's never called... I've tried with a connection closed from the server and from the browser...
All the code is here : https://github.com/davinkevin/spring-websocket-disconnect
I don't have much time today, I will try to work on it... because the auto-reconnect is something I would like to add.
@davinkevin i'm watching this but some other matters are taking my full attention... i'll catch up with this soon and get back to you! thanks for your quick reply ;)
I don't find any solution for this use case. Do you find something to enable the auto-reconnection ?
Handle some logic in the 'error callback' of connection promise seems strange for me.
A promise is evaluated only once, so if the promise succeed once, it will never reach the error callback. That's why I've searched in the StompClient disconnect callback, but without any success.
The solution should be to remove promise wrapping around stomClient connection, because both success an error should be called...
Keep working on it.
I've implemented it very simply (example here : https://github.com/davinkevin/spring-websocket-backend)
If the error callback of the stomp client is called, I reconnect by using all the parameters gave to the service before (I store it now...)
This behavior is not triggered if disconnection made manually.
Say me if it's alright for your need
Add in 0.6.1 a timeOut parameter to configure the waiting time between two try of reconnection. Without it, the system reach StackOverflow...
By default, the system is waiting 5 Seconds between each try, this value could be changed by the provider.
Excellent! :+1:
I'm reading this article and the are proposing a nice way to reconnect stomp on timeout. But I'm unable to do it using
ngstomp
.Whats the correct way to do it?