API Automation

Optimize the Network, Improve Win's Long Term Automation and Stability

1. When running automated tasks on the computer for a long time, it is possible to get "Failed to establish a new connection: [WinError 10048]". Usually each socket address (protocol/network address/port) is allowed to be used only once.


2. You can modify the registry key, to improve the network performance of computer.


3. Use the regedit command to access HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/TCPIP/Parameters. Registry subkey and create a new REG_DWORD value named TcpTimedWaitDelay. Set this value to decimal 30, which is hexadecimal 0x0000001e. This value sets the wait time to 30 seconds.


4. Use the regedit command to access HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/TCPIP/Parameters. Registry subkey and create a new REG_DWORD value named MaxUserPort. Stop and restart the system. Default value: None. Recommended value: at least decimal 32768.


5. Users who do not know how to open the registry can directly create a new TXT document, and write the following content to save it. Change the name of this new file to Tcpip.reg, and double-click to import it into the registry:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"TcpTimedWaitDelay"=dword:0000001e
"MaxUserPort"=dword:00008000


6. When the interface is invoked, using the command-line tool netstat -n, finding that nearly 4,000 connections to the IP address of the target computer running the interface are in the TIME_WAIT state , you can increase the default MaxUserPort setting and lower the TcpTimedWaitDelay setting at the same time so that the client anonymous port is not exhausted. For example, you can set MaxUserPort to 20000 and TcpTimedWaitDelay to 30.


7. A lower TcpTimedWaitDelay setting means that the socket waits less time in the TIME_WAIT state. A higher MaxUserPort setting means you can keep more sockets in the TIME_WAIT state.


8. To ensure client stability, you can restart the client for a period of time.


9. Call the local port API, GET request this address, to restart and automatically log in to the XLogin client.

http://127.0.0.1:35000/api/v1/client/restart Restart client (no request parameters).