On Mon, 2019-07-22 at 12:29 +0300, Petar Tahchiev wrote: > Hello, > I have a Tomcat server running on port 8112 via HTTPS. The Tomcat has > http2 > enabled and is running with OpenJDK11. > Now when I try to connect with HTTPClient 5.0-beta5 I get this > exception: > =================== > 2019-07-22 12:22:57,699 [https-jsse-nio-8443-exec-2] INFO : > Recoverable I/O > exception (org.apache.hc.core5.http.NoHttpResponseException) caught > when > processing request to {s}->https://localhost:8112 > 2019-07-22 12:22:57,709 [https-jsse-nio-8443-exec-2] INFO : > Recoverable I/O > exception (org.apache.hc.core5.http.NoHttpResponseException) caught > when > processing request to {s}->https://localhost:8112 > 2019-07-22 12:22:57,719 [https-jsse-nio-8443-exec-2] INFO : > Recoverable I/O > exception (org.apache.hc.core5.http.NoHttpResponseException) caught > when > processing request to {s}->https://localhost:8112 > 2019-07-22 12:22:57,732 [https-jsse-nio-8443-exec-2] ERROR: > localhost:8112 > failed to respond > org.apache.hc.core5.http.NoHttpResponseException: localhost:8112 > failed to > respond > at > org.apache.hc.core5.http.impl.io.DefaultHttpResponseParser.createConn > ectionClosedException(DefaultHttpResponseParser.java:87) > at > org.apache.hc.core5.http.impl.io.AbstractMessageParser.parse(Abstract > MessageParser.java:243) > at > org.apache.hc.core5.http.impl.io.AbstractMessageParser.parse(Abstract > MessageParser.java:53) > at > org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.receive > ResponseHeader(DefaultBHttpClientConnection.java:187) > at > org.apache.hc.core5.http.impl.io.HttpRequestExecutor.execute(HttpRequ > estExecutor.java:181) > at > org.apache.hc.core5.http.impl.io.HttpRequestExecutor.execute(HttpRequ > estExecutor.java:224) > at > org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager > $InternalConnectionEndpoint.execute(PoolingHttpClientConnectionManage > r.java:596) > at > org.apache.hc.client5.http.impl.classic.InternalExecRuntime.execute(I > nternalExecRuntime.java:220) > at > org.apache.hc.client5.http.impl.classic.MainClientExec.execute(MainCl > ientExec.java:107) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(Exec > ChainElement.java:51) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(Ex > ecChainElement.java:57) > at > org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectEx > ec.java:181) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(Exec > ChainElement.java:51) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(Ex > ecChainElement.java:57) > at > org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(Protocol > Exec.java:165) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(Exec > ChainElement.java:51) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(Ex > ecChainElement.java:57) > at > org.apache.hc.client5.http.impl.classic.RetryExec.execute(RetryExec.j > ava:88) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(Exec > ChainElement.java:51) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(Ex > ecChainElement.java:57) > at > org.apache.hc.client5.http.impl.classic.RedirectExec.execute(Redirect > Exec.java:116) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(Exec > ChainElement.java:51) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(Ex > ecChainElement.java:57) > at > org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execut > e(ContentCompressionExec.java:125) > at > org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(Exec > ChainElement.java:51) > at > org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute( > InternalHttpClient.java:175) > at > org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(C > loseableHttpClient.java:77) > at > com.nemesis.console.backend.storefront.DefaultRestAuthenticationProvi > der.authenticate(DefaultRestAuthenticationProvider.java:116) > =================== > > - If I change the URL from > https://localhost:8112/storefront/rest/auth to > https://some-website-with-valid-certificate.com/ it all works fine. > - If I change the Tomcat server to work with HTTP1.1 it all works > fine. > Here is my code: > =================== > > try { > // Trust standard CA and those trusted by our custom strategy > final SSLContext sslcontext = > SSLContexts.custom().loadTrustMaterial(new TrustStrategy() { > > @Override > public boolean isTrusted(final X509Certificate[] chain, final > String authType) throws CertificateException { > return true; > } > > }).build(); > > int timeout = 5; > > RequestConfig config = > RequestConfig.custom().setResponseTimeout(timeout, > TimeUnit.SECONDS).setConnectTimeout(timeout, > TimeUnit.SECONDS).build(); > > // Allow TLSv1.2 protocol only > final SSLConnectionSocketFactory sslSocketFactory = > SSLConnectionSocketFactoryBuilder.create().setSslContext(sslcontext). > setTlsVersions(TLS.V_1_2) > > > .setHostnameVerifier(NoopHostnameVerifier.INSTANCE).build(); > > Registry<ConnectionSocketFactory> registry = > RegistryBuilder.<ConnectionSocketFactory>create().register("https", > sslSocketFactory).build(); > > HttpClientConnectionManager ccm = new > PoolingHttpClientConnectionManager(registry); > > try (CloseableHttpClient httpclient = > HttpClients.custom().setRetryHandler(new > DefaultHttpRequestRetryHandler(3)).setDefaultRequestConfig(config) > > .setConnectionManager(ccm).build()) { > > HttpGet httpGet = new HttpGet(restBaseUrl + "auth"); > > LOG.debug("Calling: " + restBaseUrl + "auth"); > > httpGet.setHeader("test", username); > httpGet.setHeader("more-test", password); > > final HttpClientContext clientContext = > HttpClientContext.create(); > > try (final CloseableHttpResponse response2 = > httpclient.execute(httpGet, clientContext)) { > HttpEntity entity2 = response2.getEntity(); > final String response = EntityUtils.toString(entity2, > Charset.defaultCharset()); > LOG.info(response); > } > } > } catch (NoSuchAlgorithmException | KeyManagementException | > ParseException | KeyStoreException | IOException e) { > LOG.error(e.getMessage(), e); > } > > ======================= > > Any clues will be appreciated.
Hi Petar Classic HttpClient 5.0 support HTTP/1.1 version only. You need to migrate to HttpAsyncClient 5.0 to be able to use HTTP/2. For migration instructions you can refer to this migration guide https://ok2c.github.io/httpclient-migration-guide/ Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org For additional commands, e-mail: httpclient-users-h...@hc.apache.org