Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 1 KB

DOCUMENTATION.md

File metadata and controls

19 lines (16 loc) · 1 KB

connect(url, callback[, settings])

  • url <string> e.g. "ws://my-websocket.com/chat" or "wss://secure-websocket.com/login"
  • callback(client, error) <function> will be called on connection or in case of error
    • client <WebSocket> will be null in case of error
    • error <Error> only in case of error, error.code = "ECONNECT", client will be null
  • settings <Object>
    • maxMessage <number> disconnect on receiving a message bigger than maxMessage (in bytes), default is 134217728 (128 MiB)
    • validateUTF8 <boolean> enable utf8-validation, defaults to true
    • timeout <number> close pending connect or enforce pending close after timeout (in ms), default is 5000 (5 sec)
    • protocol <string[ ]> a list of sub-protocols for handshake
    • headers <Object> a list of optional headers to be sent to the server
    • auth <string> Basic authentication i.e. "user:password" to compute an Authorization header