       try
         _this.$ws.open host
       catch err
-        error_cb('Connection failed! (exception)')
+        error_cb('Connection failed! (exception)')(err.message)
       
       
   o 'socketBind(Ljava/net/InetAddress;I)V', (rs, _this, address, port) ->

        _this.$ws.on('close', ->)
        _this.$ws.on('error', ->)
      
      error_cb = (msg) -> ->
        debug msg
        clear_state()
        except_cb -> rs.java_throw rs.get_bs_class('Ljava/io/IOException;'), msg
      
      # Success case
      _this.$ws.on('open', ->

# See RFC 6455 section 7.4
websocket_status_to_message = (status) ->
  switch status
    when 1000 then return 'Normal closure'
    when 1001 then return 'Endpoint is going away'
    when 1002 then return 'WebSocket protocol error'
    when 1003 then return 'Server received invalid data'
  'Unknown status code or error'

native_methods.java.net.PlainSocketImpl = [
  o 'socketCreate(Z)V', (rs, _this, isServer) ->
    # Check to make sure we're in a browser and the websocket libraries are present
