method
WebSocket.close
code?: number,
reason?: string
): void;
Starts the closing handshake. Sends a Close frame and sets readyState to CLOSING. The close event fires once the server replies with its own Close frame and closes the connection. If the server hasn't done so after 30 seconds, Bun closes the connection.
@param code
A close code an endpoint is allowed to send (RFC 6455): 1000-1014 except the reserved 1004-1006, or 3000-4999. Any other code throws an InvalidAccessError. If omitted, the Close frame has no code or reason.
@param reason
A human-readable string explaining why the connection is closing. Throws a SyntaxError if longer than 123 bytes of UTF-8