 
             @rawSocket.on 'data', handshake_callback
 
-        @rawSocket.on 'error', (args...) => @emit 'error', args...
+        @rawSocket.on 'error', (args...) =>
+            @close({noreplyWait:false})
+            @emit 'close'
 
         @rawSocket.on 'close', =>
-            @open = false
-            @emit 'close', {noreplyWait: false}
+            @close({noreplyWait: false})
+            @emit 'close'
 
         # In case the raw socket timesout, we close it and re-emit the event for the user
         @rawSocket.on 'timeout', => @open = false; @emit 'timeout'

        ).nodeify callback

    cancel: ar () ->
        @outstandingCallbacks = {}

    reconnect: (varar 0, 2, (optsOrCallback, callback) ->

        @outstandingCallbacks = {}
        @nextToken = 1
        @open = false
        @closing = false

        @buffer = new Buffer(0)

