D
D
darkslesh2011-02-20 23:07:00
linux
darkslesh, 2011-02-20 23:07:00

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

4 answer(s)
R
rimidal, 2011-02-25
@rimidal

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.

V
VBart, 2011-02-21
@VBart

So you have a leak. And not all session terminations are handled correctly. Search with a debugger where sockets are leaking.

D
darkslesh, 2011-02-21
@darkslesh

For each connected I put

D
darkslesh, 2011-02-21
@darkslesh

SO_KEEPALIVE=1
TCP_KEEPIDLE=30
TCP_KEEPINTVL=30
TCP_KEEPCNT=2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question