# ktor


08/28/2019, 8:39 AM
Hey 🙂 I am getting Connection reset by peer
from Netty for all my requests that were answered with a 200. I understand that the client closed the connection, but why is then an exception thrown? Did somebody experience this before ?

Szymon Lipiński

08/28/2019, 9:05 AM
I think the exception is thrown because there was an IO problem. It's possible that the client closed connection on purpose. It's also possible that many different things happened, including unplugging a cable or losing electricity. I had all the cases and then I saw this exception. So I think it's perfectly fine that it's there. On production servers when I don't control all the clients, I have no idea if they closed the client, refreshed the page, or we have a huge network problem.

Sergey Akhapkin

08/28/2019, 7:59 PM
What happened on client's side? Could it be a case when response with 200 does NOT contain a body and perhaps some REST-like client tried to read body - just because client's author expects that responses without body should have 204 status. In general, 'reset by peer' means that client dropped connection (e.g. via shutdown syscall) instead of graceful closing. It could be also a kind of TCP optimization if client needs to operate with huge number of connections (because gracefully closed connection holds local port busy longer that 'dropped' one).


08/29/2019, 5:20 AM
hey, thanks guys for your explainations. So actually between the client and the ktor application is HAProxy that seems to close the connection after the „timeout connect 20s“. The client sets the header: Connection: keep-alive. That would explain the behavior. I still need to figure out what is the most performant setting (maybe „connection: close“ )