         lastPong = Date.now()
 
       failureCallback = setTimeout ->
-        log 'broker ping failed, running troubleshoot', failureCallback
-        KD.troubleshoot(false)
+        if timesTroubleshootRan > 3
+          log "broker ping failed too many times, stopping troubleshoot"
+          return
+
+        log 'broker ping failed, running troubleshoot'
+        KD.troubleshoot false
+        timesTroubleshootRan++
       , 3000
 
       KD.remote.mq.ping -> brokerPong()
-
     , 5000
 
   KD.remote.on 'connected', ->
+    resetIntervals()
     pingBrokerOnInterval()
-    log 'connected, starting broker ping', brokerInterval
-
-  KD.remote.on 'disconnected', ->
-    return unless brokerInterval?
-
-    log 'disconnected, stopping broker ping'
-
+
+  KD.remote.on 'disconnected', -> resetIntervals()
+
+  resetIntervals =->
     clearInterval brokerInterval
     clearTimeout failureCallback
     brokerInterval  = null


  KD.troubleshoot = (showNotifications=true)->
    monitorItems = KD.getSingleton("monitorItems").items
    monitor = new MonitorStatus monitorItems
    monitor.showNotifications = showNotifications
    monitor.run()

  window.jsonp = ->
    KD.externalPong()

  brokerInterval  = null
  failureCallback = null
  lastPong        = null

  # use broker ping to determine internet connection
  pingBrokerOnInterval = ->
    brokerInterval = setInterval ->
      clearTimeout failureCallback

    notifications =
      internetUp : "All systems go!"
      internetDown: "Your internet is down."
      brokerDown: "Broker is down."
      kitesDown: "Kites are down."
      bongoDown: "Bongo is down."
      undefined: "Sorry, something went wrong."

    msg = notifications[reason] or notifications["undefined"]
