react-websocket icon indicating copy to clipboard operation
react-websocket copied to clipboard

state.attempts is never reset

Open meyercm opened this issue 7 years ago • 0 comments

In the situation where periodic disconnections are expected, the component will eventually always use the max retry backoff, because a successful reconnection never resets state.attempts.

I'll happily put together a pull request if you'd like, or just add this snippet

websocket.onopen = () => {
      this.logging('Websocket connected')
      this.setState({ attempts: 1 }) // Add this line so that reconnecting resets the retry cooloff.
...

meyercm avatar Jan 24 '18 02:01 meyercm