[ https://issues.apache.org/jira/browse/HTTPCLIENT-1765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16912247#comment-16912247 ]
Jang Ryeol commented on HTTPCLIENT-1765: ---------------------------------------- Yes, I see that {{RequestConfig}} has nothing do with connection establishment. What I'm trying to say is, IF IT IS NOT THE PROBLEM, could you shed some light on where should I look for? I made this simple HTTP server that responds after 5 seconds. Nginx is front of it as proxy for both http and https. {code:python} from time import sleep from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): sleep(5); return 'Hello World!' if __name__ == '__main__': app.run(host='0.0.0.0', port=8080) {code} For {{connectTimeout}} = 1, HTTP request receives respond without exception. With same {{RequestConfig}}, HTTPS request raises a {{ReadTimeoutException}} after the {{connectTimeout}} I've set: 1 second. {code:java} public void doTest() { RequestConfig config = RequestConfig.custom() .setConnectTimeout(1000).build(); CloseableHttpClient httpclient = HttpClientBuilder.create().setDefaultRequestConfig(config).build(); /** * Success */ try { HttpGet httpGet = new HttpGet("http://test1.ryeol.me"); HttpResponse response = httpclient.execute(httpGet); log.info(IOUtils.toString(response.getEntity().getContent(), "UTF-8")); } catch (Exception e) { log.error("Error", e); } /** * ReadTimeout */ try { HttpGet httpGet = new HttpGet("https://test1.ryeol.me"); HttpResponse response = httpclient.execute(httpGet); log.info(IOUtils.toString(response.getEntity().getContent(), "UTF-8")); } catch (Exception e) { log.error("Error", e); } } {code} As you see, the behavior is inconsistent between HTTP and HTTPS, isn't it? And I found that {{connectSocket}} method of {{SSLConnectionSocketFactory}} uses same {{connectTimeout}} value that I set on {{RequestConfig}}. So I figured {{SSLConnectionSocketFactory}} might have to restore the {{soTimeout}} to its original value after connection established. {code:java} if (connectTimeout > 0 && sock.getSoTimeout() == 0) { sock.setSoTimeout(connectTimeout); } {code} And you're saying no it's not. Could you please check that what would be the reason? Or am I wrong, and you can't reproduce above? Regards, Jang Ryeol > SSLConnectionSocketFactory uses connectTimeout for read timeout > --------------------------------------------------------------- > > Key: HTTPCLIENT-1765 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1765 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient (classic) > Affects Versions: 4.5 > Environment: Any > Reporter: SATISH BURNWAL > Priority: Major > Labels: features > > SSLConnectionSocketFactory uses connect timeout value for socket.soTimeout as > well (as per the code in SSLConnectionsocketFactory). Because of this, when > clients are created with such config (below), read timeout is not taking > effect. > RequestConfig.Builder rb = RequestConfig.custom(); > rb.setConnectTimeout(3000); > rb.setExpectContinueEnabled(true); > rb.setSocketTimeout(10000); > rb.setAuthenticationEnabled(true); -- This message was sent by Atlassian Jira (v8.3.2#803003) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org