Months ago I’ve made a C# script to synchronize data from external source into a Sharepoint Site using Sharepoint CSOM and PnP.
It’s been running just fine until recently it stopped working.
I saw the logs and see a lot of
SocketException error messages like the one below.
So then I did a research and found a stackoverflow.com thread which have a simple explanation by jrista on why it happened.
You are overloading the TCP/IP stack. Windows (and I think all socket stacks actually) have a limitation on the number of sockets that can be opened in rapid sequence due to how sockets get closed under normal operation. Whenever a socket is closed, it enters the TIME_WAIT state for a certain time (240 seconds IIRC). Each time you poll, a socket is consumed out of the default dynamic range (I think its about 5000 dynamic ports just above 1024), and each time that poll ends, that particular socket goes into TIME_WAIT. If you poll frequently enough, you will eventually consume all of the available ports, which will result in TCP error 10048.
Then I did a crosscheck with the article I found from Microsoft (see references below), it turns out Windows Server has 5000 port limitation by default.
The fix is very simple, at least for now. You only need to edit / create a certain key in Registry.
To do that, open run and type
Go to following path of registry key.
Create (or edit if already exist)
MaxUserPort key with
DWORD value type. The valid range for this value is 5000-65534 (decimal).
If the key doesn’t exist, the value is set to 5000 automatically. In my case, I set it to maximum value 65534 and it works just fine.
The C# script is running again without problems. Now let’s see how long this solution can hold.
Inserting an Ad Unit to Hugo Content without Shortcode
Easy and simple guide on how to put an ad unit in the middle of article generated with Hugo