Can I count how many the errors like that occurs in k6 report? Because the only checks is on 101 return status and the messages on websocket connection. Thank youu!!
I am not certain I understood what you asked, but from the screenshot this looks like an exception(see the “source=stacktrace” at the end). This is a normal exception and is because welll … ws.connect totally didn’t manage to do anything of what you expected. I don’t know the exact reason for websocket: bad handshake but it is fairly easy to count exceptions - just wrap them in try-catch:
try {
// your ws.connect
// check for example
} catch(e) {
// here you can count it ... by for example increasing a Counter
// https://k6.io/docs/javascript-api/k6-metrics/counter
}
// this code will get executed regardless if there was an exception
// so you might want to do `throw e` in the catch if you don't want that
I hope this helps you, and if I haven’t managed to understand what you asked for a small code sample might help me better understand what you are trying to do.