Hi list,
sometime ago I updated the coap-to-http proxy of Eclipse/Californium to
apache http client 5.1.
That still runs nice using java 7.
But using java 8 or java 11, a "https" request fails with
"ProtocolException: Header 'Connection: keep-alive' is illegal for
HTTP/2 messages "
(see the log below). "http" requests are working.
What wonders me, if the request is HTTP/1.1, why is the response HTTP/2.0?
If I switch the HttpVersionPolicy.NEGOTIATE to FORCE_HTTP_1 it works
again also for "https".
I updated to 5.1.3, but that doesn't change it.
I use the code in
https://github.com/eclipse-californium/californium/blob/main/californium-proxy2/src/main/java/org/eclipse/californium/proxy2/http/HttpClientFactory.java#L96-L122
to setup the client.
-------------------------------------
HttpAsyncClientBuilder.create().disableCookieManagement()
.setDefaultRequestConfig(createCustomRequestConfig(config))
.setConnectionManager(createPoolingConnManager(config)).setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setIOReactorConfig(
IOReactorConfig.custom().setSoTimeout(Timeout.ofSeconds(connectionIdleSecs)).build())
.addRequestInterceptorFirst(new
RequestConnControl()).addRequestInterceptorFirst(new RequestDate())
.addRequestInterceptorFirst(new RequestExpectContinue())
.addRequestInterceptorFirst(new
RequestTargetHost()).addRequestInterceptorFirst(new RequestUserAgent())
.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy() {
@Override
public TimeValue getKeepAliveDuration(HttpResponse response,
HttpContext context) {
TimeValue keepAlive = super.getKeepAliveDuration(response,
context);
if (keepAlive == null || keepAlive.getDuration() < 0) {
// Keep connections alive if a keep-alive value
// has not be explicitly set by the server
keepAlive = KEEP_ALIVE;
}
return keepAlive;
}
}).build();
-------------------------------------
Removing the getKeepAliveDuration doesn't help.
I spend also a couple of hours to search the web, but in the flood of
information I was not able to solve this issue.
best regards
Achim Kraus
Eclipse/Californium
##############################################################################
07:20:59.875 DEBUG [HttpAsyncMainClientExec]: ex-0000000002 send request
GET /impressum HTTP/1.1, null entity
07:20:59.875 DEBUG [HttpAsyncMainClientExec]: ex-0000000002 execution
failed: Header 'Connection: keep-alive' is illegal for HTTP/2 messages
07:20:59.876 DEBUG [InternalAbstractHttpAsyncClient]: ex-0000000002
request failed: Header 'Connection: keep-alive' is illegal for HTTP/2
messages
07:20:59.876 DEBUG [PoolingAsyncClientConnectionManager]: ep-0000000001
close IMMEDIATE
07:20:59.876 DEBUG [DefaultManagedAsyncClientConnection]: c-0000000001
Shutdown connection IMMEDIATE
07:20:59.876 DEBUG [SSLIOSession]:
c-0000000001[ACTIVE][rw:r][ACTIVE][r][NOT_HANDSHAKING][0][0][47] Close
IMMEDIATE
07:20:59.876 DEBUG [InternalHttpAsyncClient]: ep-0000000001 endpoint closed
07:20:59.876 DEBUG [InternalHttpAsyncClient]: ep-0000000001 discarding
endpoint
07:20:59.876 DEBUG [PoolingAsyncClientConnectionManager]: ep-0000000001
releasing endpoint
07:20:59.876 DEBUG [PoolingAsyncClientConnectionManager]: ep-0000000001
connection released [route: {s}->https://cloudcoap.net:443][total
available: 0; route allocated: 0 of 50; total allocated: 0 of 250]
07:20:59.876 DEBUG [ProxyHttpClientResource]: Failed to get the http
response: Header 'Connection: keep-alive' is illegal for HTTP/2 messages
org.apache.hc.core5.http.ProtocolException: Header 'Connection:
keep-alive' is illegal for HTTP/2 messages
at
org.apache.hc.core5.http2.impl.DefaultH2RequestConverter.convert(DefaultH2RequestConverter.java:189)
at
org.apache.hc.core5.http2.impl.nio.ClientH2StreamHandler.commitRequest(ClientH2StreamHandler.java:146)
at
org.apache.hc.core5.http2.impl.nio.ClientH2StreamHandler.access$100(ClientH2StreamHandler.java:61)
at
org.apache.hc.core5.http2.impl.nio.ClientH2StreamHandler$2.sendRequest(ClientH2StreamHandler.java:176)
at
org.apache.hc.client5.http.impl.async.LoggingAsyncClientExchangeHandler$1.sendRequest(LoggingAsyncClientExchangeHandler.java:83)
at
org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.produceRequest(HttpAsyncMainClientExec.java:136)
at
org.apache.hc.client5.http.impl.async.LoggingAsyncClientExchangeHandler.produceRequest(LoggingAsyncClientExchangeHandler.java:72)
at
org.apache.hc.core5.http2.impl.nio.ClientH2StreamHandler.produceOutput(ClientH2StreamHandler.java:171)
at
org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer$H2Stream.produceOutput(AbstractH2StreamMultiplexer.java:1653)
at
org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.processPendingCommands(AbstractH2StreamMultiplexer.java:640)
at
org.apache.hc.core5.http2.impl.nio.AbstractH2StreamMultiplexer.onOutput(AbstractH2StreamMultiplexer.java:505)
at
org.apache.hc.core5.http2.impl.nio.AbstractH2IOEventHandler.outputReady(AbstractH2IOEventHandler.java:74)
at
org.apache.hc.core5.http2.impl.nio.ClientH2IOEventHandler.outputReady(ClientH2IOEventHandler.java:39)
at
org.apache.hc.client5.http.impl.async.LoggingIOSession$1.outputReady(LoggingIOSession.java:243)
at
org.apache.hc.core5.reactor.ssl.SSLIOSession.encryptData(SSLIOSession.java:589)
at
org.apache.hc.core5.reactor.ssl.SSLIOSession.access$600(SSLIOSession.java:72)
at
org.apache.hc.core5.reactor.ssl.SSLIOSession$1.outputReady(SSLIOSession.java:181)
at
org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:141)
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:829)
##############################################################################
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org