File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 8383- Accepts ` integer `
8484- Default: ` 1000 `
8585
86+ #### ` maxReconnectInterval `
87+ - The maximum number of milliseconds to delay a reconnection attempt.
88+ - Accepts ` integer `
89+ - Default: ` 30000 `
90+
8691####` reconnectDecay `
8792- The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist.
8893- Accepts ` integer ` or ` float `
Original file line number Diff line number Diff line change 7979 * reconnectInterval
8080 * - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.
8181 *
82+ * maxReconnectInterval
83+ * - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.
84+ *
8285 * reconnectDecay
8386 * - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.
8487 *
104107 debug : false ,
105108 /** The number of milliseconds to delay before attempting to reconnect. */
106109 reconnectInterval : 1000 ,
110+ /** The maximum number of milliseconds to delay a reconnection attempt. */
111+ maxReconnectInterval : 30000 ,
107112 /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
108113 reconnectDecay : 1.5 ,
109114 /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
232237 }
233238 eventTarget . dispatchEvent ( generateEvent ( 'close' ) ) ;
234239 }
240+
241+ var timeout = self . reconnectInterval * Math . pow ( self . reconnectDecay , self . reconnectAttempts ) ;
235242 setTimeout ( function ( ) {
236243 self . reconnectAttempts ++ ;
237244 connect ( true ) ;
238- } , self . reconnectInterval * Math . pow ( self . reconnectDecay , self . reconnectAttempts ) ) ;
245+ } , timeout > self . maxReconnectInterval ? self . maxReconnectInterval : timeout ) ;
239246 }
240247 } ;
241248 ws . onmessage = function ( event ) {
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ declare class ReconnectingWebSocket
2323 /** The number of milliseconds to delay before attempting to reconnect. */
2424 public reconnectInterval : number ;
2525
26+ /** The maximum number of milliseconds to delay a reconnection attempt. */
27+ public maxReconnectInterval : number ;
28+
2629 /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
2730 public reconnectDecay : number ;
2831
You can’t perform that action at this time.
0 commit comments