compilein this module depends on
show akka-remote/TestJdk9/sourceDirectorieslists the right place
akka-remote/TestJdk9/testdoesn’t run anything
withChannelBuilderOverridesis a temporary API that will go away when we ever move to Akka HTTP for the client as well
@raboof Hello. I with @dmi3zkm were tested keep-alive header and here what we found
Before testing I had a firm assumption that akka-grpc issues new http connection on each grpc call.
Then I've found out that I could set client's keep alive related setting using
The code follows:
GrpcClient(GrpcClientSettings.connectToServiceAt("localhost", 9091).withTls(false) .withChannelBuilderOverrides(_.keepAliveWithoutCalls(true) .keepAliveTime(10, TimeUnit.MINUTES) .keepAliveTimeout(1, TimeUnit.MINUTES)))
Searching code I've found client's
idleTimeout which is set to 30 minutes by default.
Although, using the wireshark I couldn't find any
Keep-Alive headers in request/response packets, the connection was reused between multiple grpc calls.
idleTimeout to 100 millis and waiting for 1 sec between each call in my test, I've seen connection reestablishing packets in the wireshark.
Then I googled for http2 (which grpc uses underneath) specification and found out the section
18.104.22.168 Connection-Specific Header Fields which states:
HTTP/2 does not use the Connection header field to indicate connection-specific header fields; in this protocol, connection-specific metadata is conveyed by other >means. An endpoint MUST NOT generate an HTTP/2 message containing connection-specific header fields; any message containing connection-specific header fields >MUST be treated as malformed (Section 22.214.171.124).
The only exception to this is the TE header field, which MAY be present in an HTTP/2 request; when it is, it MUST NOT contain any value other than "trailers".
This means that an intermediary transforming an HTTP/1.x message to HTTP/2 will need to remove any header fields nominated by the Connection header field, >along with the Connection header field itself. Such intermediaries SHOULD also remove other connection-specific header fields, such as Keep-Alive, Proxy->Connection, Transfer-Encoding, and Upgrade, even if they are not nominated by the Connection header field.
This drives me to the consclusion that http2 omits Keep-Alive headers at all and grpc connections on top of http2 is persistent out of the box.
Please, confirm or correct my assumptions.
Connectionitself etc. I suspect there's more to keepalive in grpc though: perhaps indeed
keepAliveWithoutCallsis just a matter of setting timeouts, but it suggests there also exists a 'keepalive with calls', which likely does need explicit code on the server side?