No results for

Powered byAlgolia
⚠️ This is archived documentation for v0.39. Go to the latest version

Socket.close([code])

Close the WebSocket connection.

ParameterTypeDescription
code (optional)numberWebSocket status code. (default: 1001)

Example

import ws from 'k6/ws';
export default function () {
const url = 'ws://echo.websocket.org';
const response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.close();
});
});
}