File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
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 *
105108 /** The number of milliseconds to delay before attempting to reconnect. */
106109 reconnectInterval : 1000 ,
107110 /** The maximum number of milliseconds to delay a reconnection attempt. */
108- maxReconnectInterval : - 1 ,
111+ maxReconnectInterval : 30000 ,
109112 /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
110113 reconnectDecay : 1.5 ,
111114 /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
234237 }
235238 eventTarget . dispatchEvent ( generateEvent ( 'close' ) ) ;
236239 }
237- var timeout = self . reconnectInterval * Math . pow ( self . reconnectDecay , self . reconnectAttempts ) ;
238- if ( self . maxReconnectInterval != - 1 && timeout > self . maxReconnectInterval )
239- timeout = self . maxReconnectInterval ;
240240
241+ var timeout = self . reconnectInterval * Math . pow ( self . reconnectDecay , self . reconnectAttempts ) ;
241242 setTimeout ( function ( ) {
242243 self . reconnectAttempts ++ ;
243244 connect ( true ) ;
244- } , timeout ) ;
245+ } , timeout > self . maxReconnectInterval ? self . maxReconnectInterval : timeout ) ;
245246 }
246247 } ;
247248 ws . onmessage = function ( event ) {
You can’t perform that action at this time.
0 commit comments