     , @getInterval()
 
   getInterval: ->
-    {min, max} = @pollInterval
-    interval = 4 * Math.log(@reconnectAttempts + 1)
+    {min, max} = @constructor.pollInterval
+    interval = 5 * Math.log(@reconnectAttempts + 1)
     clamp(interval, min, max) * 1000
 
   reconnectIfStale: ->
     if @connectionIsStale()
       @reconnectAttempts++
-      @consumer.connection.reopen()
+      unless @disconnectedRecently()
+        @consumer.connection.reopen()
 
   connectionIsStale: ->
-    if @pingedAt
-      secondsSince(@pingedAt) > @staleThreshold.pingedAt
-    else
-      secondsSince(@startedAt) > @staleThreshold.startedAt
+    secondsSince(@pingedAt ? @startedAt) > @constructor.staleThreshold
+
+  disconnectedRecently: ->
+    @disconnectedAt and secondsSince(@disconnectedAt) < @constructor.staleThreshold
 
   visibilityDidChange: =>
     if document.visibilityState is "visible"

# Responsible for ensuring the cable connection is in good health by validating the heartbeat pings sent from the server, and attempting
# revival reconnections if things go astray. Internal class, not intended for direct user manipulation.
class Cable.ConnectionMonitor
  identifier: Cable.PING_IDENTIFIER

  pollInterval:
    min: 2
    max: 30

  staleThreshold:
    startedAt: 4
    pingedAt: 8

  constructor: (@consumer) ->
    @consumer.subscriptions.add(this)

  connected: ->
    @reset()
    @pingedAt = now()
    delete @disconnectedAt

  disconnected: ->
    @disconnectedAt = now()

  received: ->
    @pingedAt = now()
