You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Sebastian Choina (JIRA)" <ji...@apache.org> on 2016/08/30 09:12:20 UTC

[jira] [Created] (HTTPCLIENT-1764) SocketTimeout cannot be set on per request basis when using Proxy and SSL

Sebastian Choina created HTTPCLIENT-1764:
--------------------------------------------

             Summary: SocketTimeout cannot be set on per request basis when using Proxy and SSL
                 Key: HTTPCLIENT-1764
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1764
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient
    Affects Versions: 4.5.2
            Reporter: Sebastian Choina


I have ran into the same problem described in HTTPCLIENT-1478 and IMHO it should not be closed.

Right now there is no way to set {{soTimeout}} for http tunnel establish phase causing client to hang forever in case of bad proxy. 

The workaround is to set {{defaultSockedConfig}} upon creation of the client. However IMHO, client should honor {{RequestConfig#SocketTimeout}} in this case, and if not, developer should have the ability to set {{soTimeout}} for this particular phase on request basis as well. 
Setting default configuration is one workaround, but if I would need timeout value to vary across the requests, I would have to create new client for each one and that is against the desing of reusebility of the client itself.

Here is the wire log on hanging connection. As for the time of writing, scenerio (inf. hang) is reproducable using proxy from the logs.

{noformat}
09:55:06.719 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
09:55:06.720 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
09:55:06.721 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {tls}->http://84.28.86.73:80->https://api.ipify.org:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
09:55:06.722 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 19][route: {tls}->http://84.28.86.73:80->https://api.ipify.org:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
09:55:06.723 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {tls}->http://84.28.86.73:80->https://api.ipify.org:443
09:55:06.723 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to /84.28.86.73:80
09:55:06.786 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 192.168.2.144:31914<->84.28.86.73:80
09:55:06.787 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG org.apache.http.headers - http-outgoing-19 >> CONNECT api.ipify.org:443 HTTP/1.1
09:55:06.787 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG org.apache.http.headers - http-outgoing-19 >> Host: api.ipify.org
09:55:06.788 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG org.apache.http.headers - http-outgoing-19 >> User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_66)
09:55:06.788 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG org.apache.http.wire - http-outgoing-19 >> "CONNECT api.ipify.org:443 HTTP/1.1[\r][\n]"
09:55:06.788 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG org.apache.http.wire - http-outgoing-19 >> "Host: api.ipify.org[\r][\n]"
09:55:06.789 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG org.apache.http.wire - http-outgoing-19 >> "User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_66)[\r][\n]"
09:55:06.789 [ProxyPool-ScheduledWorkers-pool-3-thread-1] DEBUG org.apache.http.wire - http-outgoing-19 >> "[\r][\n]"
{noformat}

Workaround to force timeout:
{noformat}
		client = HttpClients.custom()// the same as createDefault();
				.setDefaultSocketConfig(
						SocketConfig.custom()
								.setSoTimeout(2000)
								.build())
				.disableAutomaticRetries() // we dont want this test to take too long
				.build();
{noformat}

If we remove default socket config, client will hang



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org