       url  = "ws://#{host}:#{port}/socket.io/websocket"
       @ws = new WebSocket(url)
       @ws.onmessage = @onMessage.bind(@)
-      @ws.onerror = @onError.bind(@)
+      @ws.onerror = @disconnect.bind(@)
       @ws.onclose = @onClose.bind(@)
 
   whichServer: (roomid, callback) ->

    else
      activity = @lastActivity
    if @_isConnected and (Date.now() - activity) > @disconnectInterval
      @_isAuthenticated = false
      @_isConnected = false
      @log 'No response from server; is there a proxy/firewall problem?'
      @onError new Error 'No response from server'
    else
      @updatePresence()


      success : true


  disconnect: (err) ->
    @_isAuthenticated = false
    @_isConnected = false
    if @listeners('disconnected').length
      @emit 'disconnected', err
    else
      throw err


  onClose: ->
