Skip to content
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

Socket sends all previous messages on retry #30

Open
Flood opened this issue Apr 21, 2017 · 0 comments
Open

Socket sends all previous messages on retry #30

Flood opened this issue Apr 21, 2017 · 0 comments

Comments

@Flood
Copy link

Flood commented Apr 21, 2017

Hi!

We are using this web socket implementation. On page load everything is correct and we start sending messages etc. When we loose connection and it gets back again the websocket sends ALL previous messages directly (the messageQueue is empty).

I've commented out this section and now it just creates a new connection without sending anything.

.retryWhen(errors => errors.switchMap(err => {
      // update the connection state to let it know we're retrying
      this.connectionState.next(ConnectionStates.RETRYING);
      
      if(navigator.onLine) {
        // if we have a network connection, try again in 3 seconds
        return Observable.timer(3000);
      } else {
        // if we're offline, so wait for an online event.
        return Observable.fromEvent(window, 'online').take(1);
      }
    }));

How can we make this not send old messages? We still want the retryWhen code since we need to do stuff when we gets back online.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant