Java.net.noroutetohostexception: cannot assign requested address

Open source software supply chain lighting plan, waiting for you>>>

Question:

Error reason: because the client connection port allocated by Linux is exhausted, the socket connection cannot be established. Although the socket is closed normally, the port is not released immediately, but is in time_ Wait status. By default, wait for 60s and release
check the range of client connection ports supported by Linux, that is, 28232 portscat /proc/sys/net/ipv4/ip_ local_ port_ range
32768 - 61000

Solution:
1. Reduce the waiting time after port release, which is 60 s by default and 15 ~ 30 s by modificationecho 30 >/proc/sys/net/ipv4/tcp_ fin_ Timeout
2. Modify the TCP/IP protocol configuration by configuring /proc/sys/net/IPv4/TCP_ tw_ Reuse , default to 0, modify to 1, release time_ Wait port for new connectionecho 1 >/proc/sys/net/ipv4/tcp_ tw_ Reuse
3. Modify CTP/IP protocol configuration to recycle socket resources quickly. The default value is 0. Modify to 1echo 1 >/proc/sys/net/ipv4/tcp_ tw_ recycle

https://blog.csdn.net/weixin_ 43757847/article/details/88188091

https://my.oschina.net/shichangcheng/blog/1560864

https://stackoverflow.com/questions/32282112/error-setting-net-ipv4-tcp-tw-reuse-net-ipv4-tcp-tw-recycle-in-sysctl-conf

Wei Chengjun helped to find it

Postscript:

There’s a solution

Modify httpclient4. Idletimeout = & lt; in JMeter. Properties; timeinms> Set the time you think is reasonable. Generally, it can be set to 10-60s (it means the connection will be disconnected after 10s of free time). Note that the unit here is Ms

Reference: https://blog.csdn.net/Stesthu/article/details/87968927

Postscript:

I misunderstood this concept a little. After establishing a long connection, httpclient4.idletimeout means that the long link port will be disconnected as soon as it is idle. For example, the server will be disconnected directly when it is idle before it responds, resulting in an error. Here, the time should be set a little longer, keep a long connection, keep a connection all the time

Reference: https://www.cnblogs.com/kaibindirver/p/11957645.html To use a long connection, you need to configure the requester. See the connection section

Check whether the port is used up. Netstat – an check whether there is a port in timewait

https://i-beta.cnblogs.com/posts/edit-done; postId=11956755

Postscript:

After configuring a long connection, there will still be an error. Finally, you need to modify the release time of the port on the Mac https://www.cnblogs.com/kaibindirver/p/11958506.html

Moreover, when JMeter simulates sending a request, remember to add

C onnection:keep-alive Stay connected

Similar Posts: