mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Never stop attempting to reconnect
This commit is contained in:
parent
359f006bac
commit
d96ea7c5e4
1 changed files with 2 additions and 9 deletions
|
@ -2,7 +2,6 @@
|
|||
#= require_tree .
|
||||
|
||||
class @Cable
|
||||
MAX_CONNECTION_ATTEMPTS: 10
|
||||
MAX_CONNECTION_INTERVAL: 5 * 1000
|
||||
PING_STALE_INTERVAL: 6
|
||||
|
||||
|
@ -53,11 +52,8 @@ class @Cable
|
|||
@disconnected()
|
||||
|
||||
setTimeout =>
|
||||
if @isMaxConnectionAttemptsReached()
|
||||
@giveUp()
|
||||
else
|
||||
@incrementConnectionAttemptsCount()
|
||||
@connect()
|
||||
@incrementConnectionAttemptsCount()
|
||||
@connect()
|
||||
, @generateReconnectInterval()
|
||||
|
||||
resetConnectionAttemptsCount: =>
|
||||
|
@ -66,9 +62,6 @@ class @Cable
|
|||
incrementConnectionAttemptsCount: =>
|
||||
@connectionAttempts += 1
|
||||
|
||||
isMaxConnectionAttemptsReached: =>
|
||||
@connectionAttempts > @MAX_CONNECTION_ATTEMPTS
|
||||
|
||||
generateReconnectInterval: () ->
|
||||
interval = (Math.pow(2, @connectionAttempts) - 1) * 1000
|
||||
if interval > @MAX_CONNECTION_INTERVAL then @MAX_CONNECTION_INTERVAL else interval
|
||||
|
|
Loading…
Reference in a new issue