           return
 
         deferred.resolve result
+
+    backOff.onBackOff = (tryNumber, delay) ->
+      call = enqueue
+      user = null
+
+      notify.error """
+The connection with XO-Server has been lost.
+
+Attempt to reconnect in #{Math.round delay/1e3} seconds.
+"""
+    backOff.onReady = connect
 
     connect()
 

    # Identifier of the next request.
    nextId = 0

    # Delay in seconds to the next reconnection attempt, `null` when
    # no reconnection are attempted (currently connected).
    delay = null

    # Promises linked to the requests.
    deferreds = {}


      # success: notifier 'success'
    }

  .service 'xoApi', ($cookieStore, $location, $q, BackOff, notify) ->
    url = do ->
      # Note: The path is ignored, the WebSocket must be relative to
      # root.
