Fading Coder

One Final Commit for the Last Sprint

Home > Tools > Content

Resolving Excessive TIME_WAIT Connections on Windows Systems

Tools 2

When monitoring a Zabbix agent, an alert indicated unavailability despite the agent process running. Checking network cnonections revealed numerous TCP connections in the TIME_WAIT state, prevanting new connections to the proxy due to exhausted socket resources.

In active mode, the agent initiates connections to the proxy on port 10051, leading to TIME_WAIT states upon connection closure. Restarting the agent did not release these connections, and logs showed errors like "cannot connect to [proxy]: [0x00002747] due to insufficient system buffer space or full queue."

TIME_WAIT is a normal TCP state occurring during connection termination via a four-way handshake. The party initiating closure enters TIME_WAIT to ensure reliable termination by handling potential lost ACK packets and discarding delayed segments, with a default duration of 2MSL (Maximum Segment Lifetime).

Excessive TIME_WAIT connections can deplete local ports, hindering new TCP connections. Solutions include:

  • Method 1: Apply a Microsoft-supported fix for TIME_WAIT connections not closing after extended periods in Windows Vista, 7, Server 2008, and Server 2008 R2, available through official support channels.
  • Method 2: Modify regisrty settings to manage port allocation and TIME_WAIT duration:
    • MaxUserPort: Sets the maximum port number for ephemeral ports. Default is 5000 (0x1388), with a valid renge of 5000-65534. Increase this value to allow more available ports.
    • TcpTimedWaitDelay: Controls the time before a closed connection can be reused, representing 2MSL. Default is 240 seconds; reduce to 30 seconds to free resources faster, within a range of 30-300 seconds.

To implement Method 2, open the Registry Editor (regedit), navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, and add or modify these DWORD values as needed. Adjusting these settings helps mitigate port exhaustion from TIME_WAIT accumulation.

Related Articles

Efficient Usage of HTTP Client in IntelliJ IDEA

IntelliJ IDEA incorporates a versatile HTTP client tool, enabling developres to interact with RESTful services and APIs effectively with in the editor. This functionality streamlines workflows, replac...

Installing CocoaPods on macOS Catalina (10.15) Using a User-Managed Ruby

System Ruby on macOS 10.15 frequently fails to build native gems required by CocoaPods (for example, ffi), leading to errors like: ERROR: Failed to build gem native extension checking for ffi.h... no...

Resolve PhpStorm "Interpreter is not specified or invalid" on WAMP (Windows)

Symptom PhpStorm displays: "Interpreter is not specified or invalid. Press ‘Fix’ to edit your project configuration." This occurs when the IDE cannot locate a valid PHP CLI executable or when the debu...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.