-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop reconnection and throw error #52
Comments
Hi, I will try to find a solution to your problem, but can you provide me some code example to be sure I understand what you've tried. If you need to have an env with a WS backend, I use https://github.com/davinkevin/spring-websocket-backend for my experimentation... witch is very simple. I mainly understand you want to limit the number of retry if the connection stop. I will try to do it, but if you want, you can do a PR ;) |
Hi, Here is how I changed locally the library, by adding settings.reconnectWebSocketOnError and settings.errorCallback: in the $connect method: let errorCallback = () => {
this.deferred.reject();
this.$initConnectionState();
this.settings.timeOut >= 0 && this.settings.reconnectWebSocketOnError && this.$timeout(() => {
this.$connect();
this.$reconnectAll();
}, this.settings.timeOut);
if (!this.settings.reconnectWebSocketOnError && this.settings.errorCallback) {
this.settings.errorCallback.call();
}
}; in the send method before this.connectionState.then I added:
|
I would like to treat your request, but I don't have enough time right now, could you propose a PR for analysis ? |
Hi,
At the moment if the websocket cannot connect it retries indefinite. I would like to make it stop after a number of retries and throw an error so that in my project I can show a specific page.
I tried using ngstomp.connectionState.then(function () {}, function () {}); after calling the ngstomp subscribeTo but it works only for a new connection not for the current lost one, and it still tries to reconnect even if I call disconnect. So it tries to make new connections. I also tried setting the timeout -1 so that is does not reconnect at all and tried the reconnection from my project by using ngstomp.connect() but it did not work, the error function of the connectionState promise did not get called.
Could you please give me some ideas?
Thank you.
The text was updated successfully, but these errors were encountered: