No results for

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

Socket.send(data)

suggest edits

Send a data string through the connection. Binary data is not currently supported. You can use JSON.stringify to convert a JSON or JavaScript values to a JSON string.

ParameterTypeDescription
datastringThe data to send.

Example

import ws from 'k6/ws';
export default function () {
var url = 'ws://echo.websocket.org';
var response = ws.connect(url, null, function (socket) {
socket.on('open', function () {
socket.send('my-message');
socket.send(JSON.stringify({ data: 'hola' }));
});
});
}