Opens a WebSocket to a ws:// or wss:// url and returns the connection object. The call yields until the handshake finishes. The returned object carries Send, Close, the OnMessage and OnClose signals, and an IsClosed flag. Also reachable as WebSocket.Connect, and through the lowercase websocket global.
Main VM only. A WebSocket must be opened on the main Luau state. Calling WebSocket.connect from inside an actor raises, because the socket’s event objects would belong to the actor’s state while messages are delivered on the main one. Open the socket on the main VM and pass what you need into the actor instead.

Parameters

string
required
A ws:// or wss:// url.

Returns

WebSocket
The connected socket object.

Example

Errors