{"id":536,"date":"2023-02-07T10:19:41","date_gmt":"2023-02-07T02:19:41","guid":{"rendered":"https:\/\/www.xlogin.us\/help\/docs\/document\/api-automation\/optimize-the-network-improve-wins-long-term-automation-and-stability\/"},"modified":"2024-12-04T15:26:13","modified_gmt":"2024-12-04T07:26:13","slug":"optimize-the-network-automation","status":"publish","type":"docs","link":"https:\/\/www.xlogin.us\/help\/docs\/api-automation\/optimize-the-network-automation\/","title":{"rendered":"Optimize the Network, Improve Win's Long Term Automation and Stability"},"content":{"rendered":"\n<p class=\"has-medium-font-size\">1. When running automated tasks on the computer for a long time, it is possible to get&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\"Failed to establish a new connection: [WinError 10048]\"<\/mark>. Usually each socket address (protocol\/network address\/port) is allowed to be used only once.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><br>2. You can modify the registry key, to improve the network performance of computer.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><br>3. Use the&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">regedit<\/mark>&nbsp;command to access&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">HKEY_LOCAL_MACHINE\/SYSTEM\/CurrentControlSet\/Services\/TCPIP\/Parameters<\/mark>. Registry subkey and create a new&nbsp;REG_DWORD&nbsp;value named&nbsp;TcpTimedWaitDelay. Set this value to decimal 30, which is hexadecimal 0x0000001e. This value sets the wait time to 30 seconds.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><br>4. Use the&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">regedit<\/mark>&nbsp;command to access&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">HKEY_LOCAL_MACHINE\/SYSTEM\/CurrentControlSet\/Services\/TCPIP\/Parameters<\/mark>. Registry subkey and create a new&nbsp;REG_DWORD&nbsp;value named&nbsp;MaxUserPort. Stop and restart the system. Default value: None. Recommended value: at least decimal 32768.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><br>5. Users who do not know how to open the registry can directly <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">create a new TXT document<\/mark>, 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:<br><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Windows Registry Editor Version 5.00\n\n&#91;HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters]\n\"TcpTimedWaitDelay\"=dword:0000001e\n\"MaxUserPort\"=dword:00008000<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><br>6. When the interface is invoked, <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">using the command-line tool&nbsp;netstat -n<\/mark>, finding that nearly 4,000 connections to the IP address of the target computer running the interface are in the&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">TIME_WAIT&nbsp;<\/mark>state , you can increase the default&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">MaxUserPort&nbsp;setting <\/mark>and lower the&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">TcpTimedWaitDelay<\/mark>&nbsp;setting at the same time so that the client anonymous port is not exhausted. For example, you can set&nbsp;MaxUserPort&nbsp;to 20000 and&nbsp;TcpTimedWaitDelay&nbsp;to 30.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><br>7. A <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">lower&nbsp;TcpTimedWaitDelay<\/mark>&nbsp;setting means that the socket <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">waits less time in the&nbsp;TIME_WAIT&nbsp;state<\/mark>. A higher&nbsp;MaxUserPort&nbsp;setting means you can keep more sockets in the&nbsp;TIME_WAIT&nbsp;state.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><br>8. To ensure client stability, you can restart the client for a period of time.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><br>9. Call the local port API, GET request this address, to restart and automatically log in to the&nbsp;<strong><a href=\"https:\/\/xlogin.us\/\" data-type=\"URL\" data-id=\"https:\/\/xlogin.us\/\" target=\"_blank\" rel=\"noreferrer noopener\">XLogin&nbsp;<\/a><\/strong>client.<br><br><em><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">http:\/\/127.0.0.1:35000\/api\/v1\/client\/restart<\/mark><\/em>&nbsp;Restart client (no request parameters).<\/p>\n\n\n\n<p><br><br><br><\/p>\n","protected":false},"featured_media":0,"parent":810,"menu_order":10,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-536","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/docs\/536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/comments?post=536"}],"version-history":[{"count":3,"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/docs\/536\/revisions"}],"predecessor-version":[{"id":542,"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/docs\/536\/revisions\/542"}],"up":[{"embeddable":true,"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/docs\/810"}],"next":[{"title":"Whether Support Automation Interfaces such as Selenium and Puppeteer?","link":"https:\/\/www.xlogin.us\/help\/docs\/api-automation\/interfaces-selenium-and-puppeteer\/","href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/docs\/543"}],"prev":[{"title":"XLogin Browser Automation Test Tool Introduction","link":"https:\/\/www.xlogin.us\/help\/docs\/api-automation\/xlogin-browser-automation-test-tool-introduction\/","href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/docs\/530"}],"wp:attachment":[{"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/media?parent=536"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.xlogin.us\/help\/wp-json\/wp\/v2\/doc_tag?post=536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}