You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Nguyen Ky Thanh (Jira)" <ji...@apache.org> on 2021/02/26 00:29:00 UTC

[jira] [Commented] (HTTPASYNC-164) ParseException: Invalid protocol version when using proxy settings

    [ https://issues.apache.org/jira/browse/HTTPASYNC-164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17291312#comment-17291312 ] 

Nguyen Ky Thanh commented on HTTPASYNC-164:
-------------------------------------------

I have the same issue, the FORCE_HTTP_1 doesn't work for me.
{code:java}

// My implemetation
final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
        .disableCookieManagement()
        .useSystemProperties() // Need for proxy
        .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_1) // Need for proxy
        .setConnectionManager(asyncClientConnectionManager)
        .setDefaultRequestConfig(RequestConfig.custom()
                .setConnectTimeout(Timeout.of(defaultClientConfiguration
                        .getConnectTimeout(), TimeUnit.MILLISECONDS))
                .setResponseTimeout(Timeout.of(defaultClientConfiguration
                        .getReadTimeout(), TimeUnit.MILLISECONDS))
                .setCookieSpec(StandardCookieSpec.STRICT)
                .build())
        .build();
client.start();
return client;
{code}
I even tried to disable the proxy setting:
{code:java}
// code placeholder
java -jar -Dhttps.proxyHost=$HTTPS_PROXY_HOST -Dhttps.proxyPort=$HTTPS_PROXY_PORT \
           -Dhttp.proxyHost=$HTTP_PROXY_HOST -Dhttp.proxyPort=$HTTP_PROXY_PORT \
           my-app.jar
{code}

> ParseException: Invalid protocol version when using proxy settings
> ------------------------------------------------------------------
>
>                 Key: HTTPASYNC-164
>                 URL: https://issues.apache.org/jira/browse/HTTPASYNC-164
>             Project: HttpComponents HttpAsyncClient
>          Issue Type: Bug
>            Reporter: Carlos
>            Priority: Major
>
> Hi,
> We have upgraded our Apache HTTP Client library from version 4.1.4 to 5.0.3. We are using the async API. Overall, it's working very good. The reason for the upgrade is the need of using the new retry feature. However, we have an endpoint that requires accessing through a proxy. The problem with this one is that it's returning the following error:
> {code:java}
> org.apache.hc.core5.http.ParseException: Invalid protocol version; error at offset 0: <[0x2e][0x2f][0x30][0x31][0x32][0x33][0x34][0x35][0x36][0x37][0x38][0x39][0x3a][0x3b][0x3c][0x3d][0x3e]> 
> 	at org.apache.hc.core5.http.message.BasicLineParser.parseProtocolVersion(BasicLineParser.java:109) 
> 	at org.apache.hc.core5.http.message.BasicLineParser.parseStatusLine(BasicLineParser.java:180) 
> 	at org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParser.createMessage(DefaultHttpResponseParser.java:83) 
> 	at org.apache.hc.core5.http.impl.nio.DefaultHttpResponseParser.createMessage(DefaultHttpResponseParser.java:44) 
> 	at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parseHeadLine(AbstractMessageParser.java:115) 
> 	at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parse(AbstractMessageParser.java:167) 
> 	at org.apache.hc.core5.http.impl.nio.AbstractMessageParser.parse(AbstractMessageParser.java:51) 
> 	at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.parseMessageHead(AbstractHttp1StreamDuplexer.java:238) 
> 	at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:267) 
> 	at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:64) 
> 	at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.inputReady(ClientHttp1IOEventHandler.java:39) 
> 	at org.apache.hc.core5.reactor.ssl.SSLIOSession.decryptData(SSLIOSession.java:536) 
> 	at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$400(SSLIOSession.java:71) 
> 	at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:176) 
> 	at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:124) 
> 	at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51) 
> 	at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:179) 
> 	at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:128) 
> 	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:834)
> {code}
> Same invocation with the previous library version was perfectly. We've tried a few options, but all of them result in the same exception being thrown:
> {code:java}
>         // Option 1
>         return HttpAsyncClientBuilder.create().setProxy(HttpHost.create("http://127.0.0.1:8080")).build();
>         
>         // Option 2
>         final ProxySelector proxySelector = ProxySelector.of(new InetSocketAddress("127.0.0.1", 8080));
>         final HttpRoutePlanner routePlanner = new SystemDefaultRoutePlanner(proxySelector);
>         
>         return HttpAsyncClientBuilder.create().setRoutePlanner(routePlanner).build();
>         // Option 3
>         return HttpAsyncClients.customHttp2().setRoutePlanner(routePlanner).build();
>         // Option 4
>         return HttpAsyncClients.custom().setProxy(HttpHost.create("http://127.0.0.1:8080")).build();
>         
>         // Option 5
>         return HttpAsyncClientBuilder.create().setProxy(HttpHost.create("http://127.0.0.1:8080")).build();
> {code}
>  
> Is there a way to solve this issue? Any way to restore the previous version configuration?
> Thank you!



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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