Close the WebSocket connection.
Parameter | Type | Description |
---|---|---|
code (optional) | number | WebSocket status code. (default: 1000) . See the list of supported close codes. |
Example
A k6 script that initiates a WebSocket connection and closes it using the onopen handler.
example-websocket-close.js
The preceding example uses a WebSocket echo server, which you can run with the following command: