System Description: I have a WCF service (hosted on a Windows service itself) that is consumed by a client (also a Windows service). These two applications are designed for continuous uptime. The queue application reads records from the database, sends jobs to the WCF service for processing, which returns some information to the client, and the client saves the results back to the database.
Error Details: After about two hours, the client application can no longer connect to the WCF service reporting the error:
"There are not enough winsock resources available to complete socket initialization." ,
The second application, which runs on the same server, also starts throwing exceptions from now on:
"A network-related or specific instance error occurred while establishing a connection to SQL Server. The server was not found or is unavailable. Verify the instance name is correct and configure SQL Server to allow remote connections. (Provider: named pipe provider, error: 40 - connection could not be opened with SQL Server) "
The second application has nothing to do with the WCF client and server, it just runs on the same server and just reads / writes to the database.
Setup / server / client code:
Server Details:
- Self-hosted inside a Windows service.
- NetTcpBinding
- ReceiveTimeout = "00:00:15"
- serviceThrottling maxConcurrentCalls = "2147483647"
- maxConcurrentSessions = "2147483647"
Client Connection Class ::
public class ClientConnectionClass : ClientBase<IFileService>, IFileService, IDisposable { public void callMethod(InputRequest request) { result = base.Channel.doRequest(request); } void Dispose() { bool success = false; try { if (State != CommunicationState.Faulted) { Close(); success = true; } } finally { if (!success) { Abort(); } } } }
Client process (Windows service):
while(true) {
Possible explanations: I think that based on the first exception error, the code does not close / release socket connections or start ports for connections (note that I explicitly call the Close () method of ClientBase from ClientProcess, in addition to the implementation of the Dispose () method in ClientBase).
Notes: The client application is multi-threaded, up to 4 simultaneous threads are running simultaneously, each of which calls the WCF service. The client for the WCF service runs fully up to the 2-hour (ish) point where the Client process spits out errors, and other (unrelated) Windows services (which use network resources) also start to spit out errors.
Possible questions to answer: Am I creating / managing a class that implements the ClientBase class? Is there an easier way to debug / register the current status of the client service or WCF (I attached the perfmon.exe file, but in fact it does not provide much useful information about sockets / networks).
thanks
UPDATE: I actually wrapped the ClientConnectionClass in a 'using' statement, I'm currently testing this (it usually takes 2 hours). Refresh , this did not work.