       if @closed_permanently
         return
       else
-        logger.debug("Attempting to reconnect websocket")
+        logger.debug("Attempting to reconnect websocket #{@_number}")
         @connect()
     setTimeout retry, milliseconds
 

      @_current_handler(msg)

  _on_close : (event) ->
    logger.info("Lost websocket connection, #{event.code} (#{event.reason})")
    @socket = null

    if @_pending_ack?


class ClientConnection

  @_connection_count : 0

  constructor : (@url, @id, @_on_have_session_hook, @_on_closed_permanently_hook) ->
    @_number = ClientConnection._connection_count
    ClientConnection._connection_count = @_number + 1
    if not @url?
      @url = DEFAULT_SERVER_WEBSOCKET_URL
    if not @id?
      @id = DEFAULT_SESSION_ID

    logger.debug("Creating websocket #{@_number} to '#{@url}' session '#{@id}'")
    @socket = null
    @closed_permanently = false
    @_fragments = []
