There are some similar questions on the forum but I didn't found exactly the same issue as mine :
I've got a Windows service (My_Service) written in dotnet C++.
The service connects every 10s to severals TCP Servers.
The service runs H24.
After a while (about 8 hours) the service can't connect to any server and gives this error :
System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full <IP ADDRESS>:<PORT>
On this server, there are an Apache and a MySQL server too. When this error occurs, the web site isn't accessible anymore.
It seems that the maximum amount of TCP connections are opened on the Windows OS or anything like that.
If I restart the service (My_Service), the web site becomes accessible again without the need to restart it.
I use this method to connect to my TCP Server :
this->Server = gcnew TcpClient(); if (this->Server->ConnectAsync(address, port)->Wait(3000) == false) // erreur
In the beginning, I was thinking that I had a memory leak, or that my TcpClient was not closed properly, by I have added some logs and I am sure to close and free the Connection, and the class instance properly.
I've found this article from MSDN (there) but I am not sure it concerns my problem.
Thanks a lot for your help,
User contributions licensed under CC BY-SA 3.0