jmeter性能压测常见错误总结
一. jmeter压力测试报错:Non HTTP response message: Illegal character in path at index 43: 请求路径
问题
jmeter压力测试报错:Non HTTP response message: Illegal character in path at index 43:请求路径
原因
请求路径中用restful风格写参数,系统识别不出来这是一个变量
解决
参数使用 ${} 形式包裹起来
二. jmeter性能压测常见错误总结
jmeter常见错误:
错误一:
Response code: Non HTTP response code: java.net.SocketTimeoutException
Response message: Non HTTP response message: connect timed out
查看Load time的时间要大于request设置的connect time out时间,所以抛出该异常。可能是由于服务端有较多请求正在处理(且处理时间较长),导致JMeter不能连接上服务器而产生的。
错误二:
Java.NET.BindException: Address already in use: connect
原因:
短时间内new socket操作很多,而socket.close()操作并不能立即释放绑定的端口,而是把端口设置为TIMEWAIT 状态,过段时间(默认240s)才释放,(用netstat -na可以看到),最后系统资源耗尽(windows上是耗尽了pool of ephemeral ports ,这段区间在1024-5000之间)
解决方法:
在运行JMeter agent的机器上,添加注册表条目HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
MaxUserPort 65334
TcpTimedWaitDelay 30
错误三:
java.lang.OutOfMemoryError: Java heap space
原因&#x
三. jmeter 编写jmx脚本 遇到的报错内容汇总
报错内容
0,0,,Non HTTP response code: java.net.MalformedURLException,Non HTTP response message: Illegal character found in host: '/',test_configkeeper 1-1,text,false,Expected to find an object with property ['configSourceId'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.,784,0,1,1,null,0,0,0
报错内容也是很长,根本就看不懂啥意思,但是基本意思就是http请求没有正常发送,host不对,因为博主使用了HTTP Request Defaults,然后在HTTP Request Defaults中的server Name or ip 设置的内容是:
所以就把后面这个把他挪走就好了,仅剩下IP就好了,就解决了这个问题
报错2
Java.sql.sqlexception connot create poolableconnectionfactory
解决办法
MySQL.server 版本应该是mysql-connector-java-5.1.12-bin.jar,我一开始用的是mysql-connector-java-8.0.11.jar,版本应该是太高了。我的jre版本是1.8
报错3
ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of
代码如下:
解决办法
因为所有jmeter的内部变量都是String类型的,要做类型的强转,不能用int直接接收
// 关键代码
int after_number = Integer.parseInt(a);
报错4
在jmeter中的beanshell脚本内容中,是不支持泛型类型的填写,只能写成非泛型才能执行成功,修改后如下;如果想使用只能通过Java实现,然后打成jar包,之后在线程组导入jar包
报错5
报错内容
{“errorCode”:“InternalError”,“errorMessage”:“Could not read JSON: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 26 column 51 path $.forwarderConfigs[0].paramConfig.requestBodyPatterns.; nested exception is com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Invalid escape sequence at line 26 column 51 path $.forwarderConfigs[0].paramConfig.requestBodyPatterns.”}
原因是在请求的boby中有一串正则匹配的字符串,而这一串字符串在postman里面是可以请求成功的,但是jmeter里面不可以,因此定位问题用了很久:
"paramConfig": {
"pathPatternMatch": true,
"requestBodyPatterns": {
"echoToken": "\"echoToken\"[\\s]*:[\\s]*\"(.+?)\"",
"timeStamp": "\"timeStamp\"[\\s]*:[\\s]*\"(.+?)\"",
"version": "\"version\"[\\s]*:[\\s]*\"(.+?)\"",
"hotelSystemHotelId": "\"hotelId\"[\\s]*:[\\s]*\"(.+?)\""
}
}
解决办法:
就是在这个地方由 [\s]换成 [\\s]
"paramConfig": {
"pathPatternMatch": true,
"requestBodyPatterns": {
"echoToken": "\"echoToken\"[\\\s]*:[\\\s]*\"(.+?)\"",
"hotelSystemHotelId":"\"hotelId\"[\\\s]*:[\\\s]*\"(.+?)\"",
"timeStamp": "\"timeStamp\"[\\\s]*:[\\\s]*\"(.+?)\"",
"version": "\"version\"[\\\s]*:[\\\s]*\"(.+?)\""
}
}
报错6
报错内容
Error invoking bsh method: eval Sourced file: inline evaluation of: import java.text.SimpleDateFormat; import org.apache.jmeter.protocol.http.sample . . . '' Token Parsing Error: Lexical error at line 11, column 77. Encountered: "\n" (10), after : "\"{\\\"forwarderKey\\\": \\\"zoeOPERADERBYTEST9188\\\",\\\"type\\\": \\\"Kafka\\\"," 2021-06-24 15:54:16,086 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of:import java.text.SimpleDateFormat; import org.apache.jmeter.protocol.http.sample . . . ‘’ Token Parsing Error: Lexical error at line 11, column 77. Encountered: “\n” (10), after : “”{\“forwarderKey\”: \“zoeOPERADERBYTEST9188\”,\“type\”: \“Kafka\”,"
报错原因
定义String时换了行,所以报错
解决办法
定义时不换行
jmeter压力测试报错:Non HTTP response message: Illegal character in path at index 43: 请求路径