在Windows Server 2003执行JMeter,当并发线程数较高时(尤其是测试机器还存在连接其他服务器的socket),可能会产生address already in use的异常。
搜索一番,很多文章指出是Windows的bug。通过在测试机器添加注册表项MaxUserPort、TcpTimedWaitDelay,并设置恰当值可解决该错误(当没有这两个注册表项时);或者修改为合适的值(如果已经存在这两个注册表项)。
方法:
在运行JMeter agent的机器上上添加注册表条目MaxUserPort和TcpTimedWaitDelay,分别设置值为65534、30,以增大可分配的tcp连接端口数、减小处于TIME_WAIT状态的连接的生存时间。
Value Name: MaxUserPort
Value Type: DWORD
Value data: 65534
Valid Range: 5000-65534 (decimal)
Default: 0x1388 (5000 decimal)
Description: This parameter controls the maximum port number that is used when a program requests any available user port from the system. Typically , ephemeral (short-lived) ports are allocated between the values of 1024 and 5000 inclusive.