File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 104
104
debug : false ,
105
105
/** The number of milliseconds to delay before attempting to reconnect. */
106
106
reconnectInterval : 1000 ,
107
+ /** The maximum number of milliseconds to delay a reconnection attempt. */
108
+ maxReconnectInterval : - 1 ,
107
109
/** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
108
110
reconnectDecay : 1.5 ,
109
111
/** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
232
234
}
233
235
eventTarget . dispatchEvent ( generateEvent ( 'close' ) ) ;
234
236
}
237
+ var timeout = self . reconnectInterval * Math . pow ( self . reconnectDecay , self . reconnectAttempts ) ;
238
+ if ( self . maxReconnectInterval != - 1 && timeout > self . maxReconnectInterval )
239
+ timeout = self . maxReconnectInterval ;
240
+
235
241
setTimeout ( function ( ) {
236
242
self . reconnectAttempts ++ ;
237
243
connect ( true ) ;
238
- } , self . reconnectInterval * Math . pow ( self . reconnectDecay , self . reconnectAttempts ) ) ;
244
+ } , timeout ) ;
239
245
}
240
246
} ;
241
247
ws . onmessage = function ( event ) {
You can’t perform that action at this time.
0 commit comments