A handler for a WebSocket connection open event. For multiple, simultaneous event handlers, use WebSocket.addEventListener().
Example
A k6 script that initiates a WebSocket connection and sets up a handler for the open event.
example-websocket-onopen.js
The preceding example uses a WebSocket echo server, which you can run with the following command: