TCP Connection not closed for HTTP - Server


I have a little problem with handling of tcp connections for a http server:

If a client connects to the http server a TcpConnection is created. If the client disconnects the PeerClosed object is received in the TcpConnection. But the TcpConnection is not closed because the ‘keepOpenOnPeerClosed’ is set to true in the Register message by the TcpStreamLogic (located in TcpStages.scala). Therefore the connection will only be closed when the “idle-timeout” is reached. When the limit of allowed TcpConnections is reached the tcp socket used for the http connections is closed leading to a dead http server.

Is this a bug or do I miss something?

Thank you very much.

Hi @jk,

that should not be the case (and a quick try did not show that behavior). You are right that keepOpenOnPeerClosed is set but that does only mean that the TcpConnection itself isn’t automatically closing the connection. Instead, the PeerClosed event will be handled by the higher layers to also close the server side of the socket.

Can you post instructions to reproduce that behavior? Can you post logs with the settings:

akka.loglevel = DEBUG = true



I have created an issue in github and provided a PR to start a discussion on that topic.

I was able to close the tcp connection by adding a “connection: close” to response header if keep alive is missing. But why is this necessary?