[
https://issues.apache.org/jira/browse/HTTPCLIENT-2236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17611394#comment-17611394
]
Lubos Kolarik commented on HTTPCLIENT-2236:
-------------------------------------------
Of course. Thanks for quick response
With HttpHost specified:
{code:java}
java.net.SocketTimeoutException: 500 MILLISECONDS
at
org.apache.hc.core5.io.SocketTimeoutExceptionFactory.create(SocketTimeoutExceptionFactory.java:50)
at
org.apache.hc.core5.reactor.InternalConnectChannel.onTimeout(InternalConnectChannel.java:93)
at
org.apache.hc.core5.reactor.InternalChannel.checkTimeout(InternalChannel.java:67)
at
org.apache.hc.core5.reactor.SingleCoreIOReactor.checkTimeout(SingleCoreIOReactor.java:241)
at
org.apache.hc.core5.reactor.SingleCoreIOReactor.validateActiveChannels(SingleCoreIOReactor.java:168)
at
org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:130)
at
org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.base/java.lang.Thread.run(Thread.java:829){code}
With HttpHost being null:
{code:java}
org.apache.hc.client5.http.ConnectTimeoutException: Connect to
http://10.255.255.0:80 [/10.255.255.0] failed: 500 MILLISECONDS
at
org.apache.hc.core5.io.SocketTimeoutExceptionFactory.create(SocketTimeoutExceptionFactory.java:50)
at
org.apache.hc.core5.reactor.InternalConnectChannel.onTimeout(InternalConnectChannel.java:93)
at
org.apache.hc.core5.reactor.InternalChannel.checkTimeout(InternalChannel.java:67)
at
org.apache.hc.core5.reactor.SingleCoreIOReactor.checkTimeout(SingleCoreIOReactor.java:241)
at
org.apache.hc.core5.reactor.SingleCoreIOReactor.validateActiveChannels(SingleCoreIOReactor.java:168)
at
org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:130)
at
org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.base/java.lang.Thread.run(Thread.java:829){code}
Not sure if it will help though. The stack trace is still the same, because of
the way how ConnectTimeoutException is created from SocketTimeoutException in
ConnectExceptionSupport.enhance
{code:java}
final IOException ex = createConnectTimeoutException(cause, namedEndpoint,
remoteAddresses);
ex.setStackTrace(cause.getStackTrace());
return ex; {code}
> Wrong exception on connect timeout when host is defined
> -------------------------------------------------------
>
> Key: HTTPCLIENT-2236
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2236
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient (async)
> Affects Versions: 5.1.3
> Reporter: Lubos Kolarik
> Priority: Minor
>
> Hi,
> it seems that when connection timeout occurs on http call, resulting
> exception is different depending on whether {{HttpHost}} is passed to execute
> method or not.
> I am using
> {code:java}
> public final <T> Future<T> execute(
> final HttpHost target,
> final AsyncRequestProducer requestProducer,
> final AsyncResponseConsumer<T> responseConsumer,
> final HandlerFactory<AsyncPushConsumer> pushHandlerFactory,
> final HttpContext context,
> final FutureCallback<T> callback) {code}
> method to execute the request. But the resulting exception depends on whether
> `target` is null or not.
> When target is null, and connection timeout occurs, then the result is
> {{org.apache.hc.client5.http.ConnectTimeoutException}} (correct), but when I
> provide the target instance myself, then the result is
> {{{}java.net.SocketTimeoutException{}}}.
> I think the problem is within
> {{org.apache.hc.client5.http.impl.nio.MultihomeIOSessionRequester#connect}}
>
> [Here|https://github.com/apache/httpcomponents-client/blob/f3b96ff82aaa4c76e88ba796c3303cd43e89ccf6/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/MultihomeIOSessionRequester.java#L69]
> when the target is provided, the {{remoteAddress}} is not null, and the
> `connectionInitiator.connect` is called directly. When SocketTimeoutException
> is throws here, it is passed directly to the callback
> But when the address is not provided, then {{connectionInitiator.connect}} is
> called
> [later|https://github.com/apache/httpcomponents-client/blob/f3b96ff82aaa4c76e88ba796c3303cd43e89ccf6/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/MultihomeIOSessionRequester.java#L107]
> with custom callback. This custom callback also handles the
> {{SocketTimeoutException}} and rethrows {{ConnectTimeoutException}}
>
> I would expect that for both cases the exception will be the same. Or am I
> doing something wrong here.
> Thanks for info
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]