Answer the question
In order to leave comments, you need to log in
Large number of CLOSE_WAIT in Linux
Strictly speaking, the situation is as follows. There is a self-written software that processes client requests. Any termination of a session with clients is organized through:
And over time, a huge number of connections with the CLOSE_WAIT status accumulate on the server (up to 90,000 connections). What could be the problem? shutdown or in some specific system settings? And is it possible to organize the automatic killing of such hanging connections (let's say by timeout)?
shutdown(sock, SHUT_RDWR);
close(sock);
Answer the question
In order to leave comments, you need to log in
The CLOSE_WAIT timeout is not adjustable in Linux.
The CLOSE_WAIT socket state is when a fin has arrived from the remote side, and the local socket is still held by the program, and has not yet sent its fin in response.
Look in your software for why the socket is not released.
So you have a leak. And not all session terminations are handled correctly. Search with a debugger where sockets are leaking.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question