场景:用JMeter做压力测试的时候,一段时间后Aggregate Report报告里的错误率就一直上升,查看View Results Tree报告时发现报如下错误:

Response code:Non HTTP response code: java.net.BindException

Response message:Non HTTP response message: Address already in use: connect

 

这个是因为发送HTTP请求时需要为TCP/IP连接分配一个临时端口,客户端关闭连接后,连接会有60s时间处于等待状态。JMeter做压测时每秒发送数千个HTTP请求,系统会耗尽可供分配的临时端口造成临时端口不够用,可以在注册表里设置一下解决这个报错。

1. 问题原因描述:(网上找来的)

When an HTTP request is made, an ephemeral port is allocated for the TCP / IP connection. The ephemeral port range is 32678 – 61000. After the client closes the connection, the connection is placed in the TIME-WAIT state for 60 seconds.

If JMeter (HttpClient) is sending thousands of HTTP requests per second and creating new TCP / IP connections, the system will run out of available ephemeral ports for allocation.

Otherwise, the following messages may appear in the JMeter JTL files:

Non HTTP response code: java.net.BindException
Non HTTP response message: Address already in use

The solution is to enable fast recycling TIME_WAIT sockets.

2. 具体修改注册表如下:

进入注册表HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters,右键新建如下2项:

右键New->DWORD (32-bit) Value, 名称输入:TcpTimedWaitDelay,修改值为30(十进制),如下图所示。设置等待时间为30s。

 

右键New->DWORD (32-bit) Value, 名称输入:MaxUserPort,修改值为65534(十进制),如下图所示。设置最大连接数为65534。

 

设置完成后重启电脑。再使用JMeter测试之前的脚本就不会再报此错误。
————————————————
版权声明:本文为CSDN博主「chensn02」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/annie810/article/details/120655577

发表评论

邮箱地址不会被公开。 必填项已用*标注