Caused by: java.net.NoRouteToHostException: No route to host using apache http client

问题描述 投票:0回答:0

我想要达到的目标:

向第三方服务器发送大量http请求

问题:

间歇性地面对这个问题我很难理解

同样,这只是间歇性的。

2023-05-16 08:33:01 1 DEBUG --- [main] [,] o.a.h.impl.nio.client.MainClientExec : [exchange: 1] start execution
2023-05-16 08:33:01 1 DEBUG --- [main] [,] o.a.h.c.protocol.RequestAddCookies : CookieSpec selected: default
2023-05-16 08:33:01 1 DEBUG --- [main] [,] o.a.h.c.protocol.RequestAuthCache : Re-using cached 'basic' auth scheme for https://third-party-server.com:9200
2023-05-16 08:33:01 1 DEBUG --- [main] [,] o.a.h.c.protocol.RequestAuthCache : No credentials for preemptive authentication
2023-05-16 08:33:01 1 DEBUG --- [main] [,] o.a.h.i.n.c.InternalHttpAsyncClient : [exchange: 1] Request connection for {s}->https://third-party-server.com:9200
2023-05-16 08:33:01 1 DEBUG --- [main] [,] o.a.h.i.n.c.PoolingNHttpClientConnectionManager : Connection request: [route: {s}->https://third-party-server.com:9200][total kept alive: 0; route allocated: 0 of 10; total allocated: 0 of 30]
2023-05-16 08:33:11 1 DEBUG --- [pool-5-thread-1] [,] o.a.h.i.n.c.PoolingNHttpClientConnectionManager : Connection request failed
java.net.NoRouteToHostException: No route to host
        at java.base/sun.nio.ch.Net.pollConnect(Native Method)
        at java.base/sun.nio.ch.Net.pollConnectNow(Unknown Source)
        at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
        at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
        at java.base/java.lang.Thread.run(Unknown Source)
2023-05-16 08:33:11 1 DEBUG --- [pool-5-thread-1] [,] o.a.h.i.n.c.InternalHttpAsyncClient : [exchange: 1] connection request failed

注:

其他项目使用不同的 http 客户端,例如 Netty、Okhttp 等,当它们在同一时间戳触发请求时,没问题

问题:

请问这是什么意思?

是不是第三方服务器的问题?还是我这个客户?

我该怎么做才能避免这种情况?我可以做些什么来进一步调试这个问题?

java apache-httpclient-4.x apache-httpasyncclient
© www.soinside.com 2019 - 2024. All rights reserved.