Closed GMchris closed 5 years ago
Hey, what if you console.log
out the event listeners?
I've done that just now to re-verify & the onmaximum
callback is triggered correctly.
$.onopen = e => { num=0; (opts.onopen || noop)(e); }; There should't do num = 0, otherwise, num will lose the original purpose as a global counter @lukeed @GMchris
@DarcyXf It isn't meant to be global. The onopen
callback is only called when the connection has been successfully established. We reset the num
counter because we want to allow maxAttempts
for every new reconnection.
For example, with a maxAttempts
of 3 and without resetting every successful connection, this would be the series of events:
new Sockette({ maxAttempts:3, timeout:1000 })
//=> 0
*server shutdown*
*wait 1s*
*attempt*
//=> 1
*wait 1s*
*attempt*
//=> 2
*RECONNECTED*
//=> 2
*server shutdown*
*wait 1s*
*attempt*
//=> 3
*GIVE UP FOREVER*
Instead, we'd want try again 3 times per connection failure.
If you have any more insight for this @GMchris please let me know – I know it's been a while but it'd be very helpful 🙇
Closing in the meantime as I'm still unable to reproduce this.
Am I misunderstanding this method or is it not working?
I have this snippet setup. Everything works as expected. When the WS server is down, Sockette tries to connect twice, before giving up, however the
onmaximum
callback is never triggered.