I’m working with websockets and I’m having an issue with the WS being disconnected more or less 45 seconds into the test with the error
"error":"websocket: close 1005 (no status)"
From the server side, I don’t see any other hint apart from the socket being disconnected
disconnecting {"socket":"PFTnL9ZeI7GHScczAAAE"}
Maybe there is a timeout I’m not aware of? thank you!
using the setInterval I’m also seeing this message:
setInterval 1 was stopped because the VU iteration was interrupted
import { WebSocket } from 'k6/experimental/websockets';
import { setInterval } from 'k6/experimental/timers';
export const options = {
scenarios: {
my_scenario: {
executor: 'constant-vus',
vus: 1,
duration: '5m',
},
},
};
export default async function () {
// Connect to the WS and subscribe to the channel
const ws = new WebSocket(`${webSocketURL}/socket/`);
ws.onopen = () => {
console.log('WebSocket connection established!');
ws.send(`42["subscribe","${channel}"]`);
console.log('Subscribed to channel: ' + channel);
const intervalId = setInterval(() => {
ws.send(JSON.stringify({ event: 'SAY', message: `I'm saying hELLO` }));
}, 3000); // say something every 3 seconds
ws.onmessage = (message) => {
if (message.data.includes(driver_channel)) {
// Check if the data is present and matches the expected value
check(message.data, { 'the received message matches the expected one': (value) => value.includes(JSON.stringify(redisData.data)) });
}
};
ws.onerror = (e) => {
console.log(e);
//ws.close();
};
ws.onclose = (e) => {
console.log('WebSocket closed:', e);
};
};
}