Skip to content

Commit 3e8cfa3

Browse files
author
Charlie Somerville
committed
reset reconnectAttempts to zero when user calls open()
1 parent 56d449d commit 3e8cfa3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

reconnecting-websocket.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,13 @@
201201
this.open = function (reconnectAttempt) {
202202
ws = new WebSocket(self.url, protocols || []);
203203

204-
if (!reconnectAttempt) {
204+
if (reconnectAttempt) {
205+
if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
206+
return;
207+
}
208+
} else {
205209
eventTarget.dispatchEvent(generateEvent('connecting'));
206-
}
207-
208-
if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
209-
return;
210+
this.reconnectAttempts = 0;
210211
}
211212

212213
if (self.debug || ReconnectingWebSocket.debugAll) {

0 commit comments

Comments
 (0)