Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Information Provided
-
5.1.3
-
None
-
None
Description
NOTE: Not using Proxy
In attempting to do a GET against a CloudFront resource I started to get `Invalid protocol version` exceptions without using a Proxy (as other users have faced as a known issue with this client). Strangely I am seeing this issue when jumping between JDK versions. I noticed that the issue shows up only when Negotiating Http protocol (Forcing to Http_1.1 or Http_2 works perfectly fine).
Lines of interest:
SSLIOSession.java:545 is only called JDK 16+
SSLIOSession.java:574
BasicLineParser.java:103 buffer does not contain the expected "HTTP" protoname
Issue detected on:
JDK 17.0.2 https://jdk.java.net/archive/
JDK 16.0.2 https://jdk.java.net/archive/
Working successfully on:
JDK 15.0.2 https://jdk.java.net/archive/
Reproduce:
import org.apache.hc.client5.http.async.methods.SimpleResponseConsumer import org.apache.hc.client5.http.impl.async.HttpAsyncClients import org.apache.hc.core5.http.nio.support.AsyncRequestBuilder fun main() { val client = HttpAsyncClients.custom() // .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_2) .build() client.start() val requestProducer = AsyncRequestBuilder .create("GET") .setUri("https://www.google.com") .build() val response = client.execute( requestProducer, SimpleResponseConsumer.create(), null, null ).get() println(response?.bodyText) }
Exception:
Exception in thread "main" java.util.concurrent.ExecutionException: 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]d[0x3d][0x3e][0x3f][0x40][0x41][0x42][0x43][0x44][0x45][0x46][0x47][0x48][0x49][0x4a][0x4b][0x4c][0x4d][0x4e][0x4f][0x50][0x51][0x52][0x53][0x54][0x55][0x56][0x57][0x58][0x59][0x5a][0x5b][0x5c][0x5d][0x5e][0x5f][0x60][0x61][0x62][0x63][0x64][0x65][0x66]http2_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 MainKt.http5Client(Main.kt:41) at MainKt.main(Main.kt:21) at MainKt.main(Main.kt)Caused by: 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]d[0x3d][0x3e][0x3f][0x40][0x41][0x42][0x43][0x44][0x45][0x46][0x47][0x48][0x49][0x4a][0x4b][0x4c][0x4d][0x4e][0x4f][0x50][0x51][0x52][0x53][0x54][0x55][0x56][0x57][0x58][0x59][0x5a][0x5b][0x5c][0x5d][0x5e][0x5f][0x60][0x61][0x62][0x63][0x64][0x65][0x66]http2_handshake_failed> at org.apache.hc.core5.http.message.BasicLineParser.parseProtocolVersion(BasicLineParser.java:110) at org.apache.hc.core5.http.message.BasicLineParser.parseStatusLine(BasicLineParser.java:181) 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:256) at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:285) 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:574) at org.apache.hc.core5.reactor.ssl.SSLIOSession.access$400(SSLIOSession.java:72) at org.apache.hc.core5.reactor.ssl.SSLIOSession$1.inputReady(SSLIOSession.java:172) at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:131) 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:85) at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44) at java.base/java.lang.Thread.run(Thread.java:833) Process finished with exit code 1
Apologies if another non-issue. I've been having a hard time trying to look this one up and the other related did not seem applicable due to me not using a proxy. Hopefully this will help some other poor soul.