繁体   English   中英

K6:如何计算错误握手错误(Websocket)

[英]K6: How to Count error Bad Handshake (Websocket)

目前我正在对 websocket 进行负载测试,然后我遇到了很多这样的错误

在此处输入图片说明

然后我会计算发生了多少错误,并在报告中提供。 我试过这个方法:

let errHandshake = new Counter("error_handshake");

if (res.status === 101) {
    errHandshake.add(0);
  } else {
    errHandshake.add(1);
  }

但它没有用,报告只显示0。像这样在此处输入图片说明

任何人都可以有一个想法或可能有帮助的东西吗?

总之非常感谢!

尝试使用 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 

错误握手

参考: https ://community.k6.io/t/how-to-count-bad-handshake-websocket/1038

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM