Ricardo Pereira created HTTPCLIENT-2248:
-------------------------------------------

             Summary: Async HTTP/2 with SOCKS and HTTPS fails
                 Key: HTTPCLIENT-2248
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2248
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient (async)
    Affects Versions: 5.2
            Reporter: Ricardo Pereira


Running the following:
{code:java}
try (CloseableHttpAsyncClient httpclient =
        HttpAsyncClients.customHttp2()
                .setIOReactorConfig(
                        IOReactorConfig.custom()
                                .setSocksProxyAddress(new 
InetSocketAddress("127.0.0.1", 9150))
                                .build())
                .build()) {
    httpclient.start();

    final HttpHost target = new HttpHost("https", "nghttp2.org");
    final SimpleHttpRequest request =
            
SimpleRequestBuilder.get().setHttpHost(target).setPath("/httpbin/ip").build();

    System.out.println("Executing request " + request);
    final Future<SimpleHttpResponse> future =
            httpclient.execute(
                    SimpleRequestProducer.create(request),
                    SimpleResponseConsumer.create(),
                    new FutureCallback<SimpleHttpResponse>() {

                        @Override
                        public void completed(final SimpleHttpResponse 
response) {
                            System.out.println(request + "->" + new 
StatusLine(response));
                            System.out.println(response.getBody());
                        }

                        @Override
                        public void failed(final Exception ex) {
                            System.out.println(request + "->" + ex);
                        }

                        @Override
                        public void cancelled() {
                            System.out.println(request + " cancelled");
                        }
                    });
    future.get();
}
{code}

Results in:
{noformat}
Executing request GET https://nghttp2.org/httpbin/ip
GET https://nghttp2.org/httpbin/ip->javax.net.ssl.SSLHandshakeException: TLS 
handshake failed
Exception in thread "main" java.util.concurrent.ExecutionException: 
javax.net.ssl.SSLHandshakeException: TLS handshake failed
        at 
org.apache.hc.core5.concurrent.BasicFuture.getResult(BasicFuture.java:72)
        at org.apache.hc.core5.concurrent.BasicFuture.get(BasicFuture.java:85)
        at 
org.apache.hc.client5.http.examples.AsyncH2Socks.main(AsyncH2Socks.java:77)
Caused by: javax.net.ssl.SSLHandshakeException: TLS handshake failed
        at 
org.apache.hc.core5.reactor.ssl.SSLIOSession.updateEventMask(SSLIOSession.java:454)
        at 
org.apache.hc.core5.reactor.ssl.SSLIOSession.setEventMask(SSLIOSession.java:791)
        at 
org.apache.hc.core5.reactor.SocksProxyProtocolHandler.inputReady(SocksProxyProtocolHandler.java:242)
        at 
org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:624)
        at 
org.apache.hc.core5.reactor.ssl.SSLIOSession.access$200(SSLIOSession.java:74)
        at 
org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:202)
        at 
org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:142)
        at 
org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
        at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178)
        at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127)
        at 
org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:86)
        at 
org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
        at java.base/java.lang.Thread.run(Thread.java:829)
{noformat}

If the scheme is changed to HTTP it succeeds:
{noformat}
Executing request GET http://nghttp2.org/httpbin/ip
GET http://nghttp2.org/httpbin/ip->HTTP/2.0 200 OK
SimpleBody{content length=32, content type=application/json}
{noformat}





--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to