Close_wait 에 대한 설명

Explaining Close_Wait

https://blogs.technet.com/janelewis/archive/2010/03/09/explaining-close-wait.aspx

 

위의 포스트에서는 다수의 connection 들이 time_wait 상태에 있어서 서버에 문제가 생긴 문제에 대해서 설명하고 있습니다. 일반적으로 Server 와 Client 에서 Socket 관련 처리를 잘못할 경우 많은 수의 connection 들이 close_wait 상태가 되고 결국 시스템에서 사용할 수 있는 포트를 모두 잠식하게 되어 network 연결이 안 되는 문제를 일으킬 수 있습니다.

Close_wait 이라는 상태는 클라이언트에서는 Connection을 끊었지만 아직 Server 에서는 끊지 않았을 때를 나타 냅니다. RFC793에 따르면 Maximum Segment Litetime 의 2배인 4분 동안 connection이 유지될 수 있습니다.

아래 두 키를 수정하여 최대 사용할 수 있는 포트와 connection 을 끊는 시간을 조절할 수 있습니다.

HKEY_Local_Machine\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

• MaxUserPort

This entry makes more ports available. 

• TcpTimedWaitDelay

 

netstat의 상태는 아래와 같습니다.

FIN_WAIT_1 Indicates active close.

TIMED_WAIT Client enters this state after active close.

CLOSE_WAIT Indicates passive close. Server just received first FIN from a client.

FIN_WAIT_2 Client just received acknowledgment of its first FIN from the server.

LAST_ACK Server is in this state when it sends its own FIN.

CLOSED Server received ACK from client and connection is closed.

 

 

감사합니다.