gpt4 book ai didi

windows - JMeter 负载测试 - HttpHostConnectException : Connection refused: connect on windows server 2012

转载 作者:行者123 更新时间:2023-12-04 13:08:19 28 4
gpt4 key购买 nike

我正在使用 JMeter 对我的应用程序进行负载测试。负载测试在 MacBook 和 Windows 10 系统上成功运行 1000 个线程,没有任何错误。

但是,当我在 Windows Server 2012 上运行时,它运行良好的 100 个线程,但是当我将线程增加到 250 或 500 时,我收到以下错误:

  org.apache.http.conn.HttpHostConnectException: Connect to localhost:8050 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$JMeterDefaultHttpClientConnectionOperator.connect(HTTPHC4Impl.java:404)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:935)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:646)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.net.ConnectException: Connection refused: connect
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:493)
at java.base/sun.nio.ch.Net.connect(Net.java:482)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:339)
at java.base/java.net.Socket.connect(Socket.java:603)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 19 more

我正在使用 Apache Jmeter - 5.4.1。

我花了一整天的时间寻找解决方案,但没有成功。有很多类似的问题,但对我的情况没有帮助。

我认为需要进行一些配置更改,但不完全是。

更新 1

我也更新了 TCP/IP 注册参数(但没有成功):

TcpTimedWaitDelay:REG_DWORD=0x0000001e(30)最大用户端口:REG_DWORD=0x0000fffe(65534)TcpNumConnections:REG_DWORD=0x00fffffe(1677214)

更新 2

看来问题不在于操作系统版本,而在于那台特定的机器。我在虚拟 Box 中的笔记本电脑上安装了 Windows Server 2012 并对其进行了测试。我发送了 500 个线程的请求,没有任何错误。

主机系统规范:8 GB RAM、4 CPU、Windows 10
访客系统规范:4 GB RAM,2 个 CPU,windows server 12

更新 3

配置截图:

enter image description here

有人可以帮忙吗?谢谢。

最佳答案

这更像是一个serverfault问题,但您可以使用以下解决方案进行调整:

  1. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

TcpMaxDataRetransmissions - Timeout limit of TCP unacknowledged data segments retransmission on actual connection = 5.

  1. 更新临时 TCP 端口范围

To change the port range, use this command:

netsh int <ipv4|ipv6> set dynamic <tcp|udp> start=number num=range
  1. 添加关机命令

because a reboot is required for the TCP stack changes.

Increase Pool Size for Ephemeral TCP Ports

 Get-Item 'HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters' | New-ItemProperty -Name MaxUserPort -Value 65534 -Force | Out-Null
Get-Item 'HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters' | New-ItemProperty -Name TcpTimedWaitDelay -Value 30 -Force | Out-Null
Get-Item 'HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters' | New-ItemProperty -Name TcpNumConnections -Value 16777214 -Force | Out-Null
Get-Item 'HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters' | New-ItemProperty -Name TcpMaxDataRetransmissions -Value 5 -Force | Out-Null
shutdown -r -t 0

关于windows - JMeter 负载测试 - HttpHostConnectException : Connection refused: connect on windows server 2012,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68325447/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com