     # enable below to autoReconnect when the socket has been closed
     if @autoReconnect
       process.nextTick => @setBackoffTimeout @bound "connect"
+
+    if @errState is ERROR
+      @emit 'error', "Websocket error!"
+      @errState = OKAY
+
     @emit 'info', "#{ @options.url }: disconnected, trying to reconnect..."
     return
 

    @proto.handle req  if req?
    return

  onError: ({ data }) ->
    @emit 'info', "#{ @options.url } error: #{ data }"
    return

  wrapMessage: (method, params, callback) ->
    authentication    : @authentication
    withArgs          : params
    responseCallback  : (response) ->
      { withArgs:[{ error: err, result }]} = response


  # ready states:
  [ NOTREADY, READY, CLOSED ] = [0,1,3]

  # error states:
  [ OKAY, ERROR ] = [0,1]

  uniqueId = "#{ Math.random() }" 

