Reputation: 373
I have faced the problem with the connection limited in WCF. My WCF service was hosted in IIS and my windows form application client connects to WCF. In the Windows_Closed event, I call the client.Close() method to notify the WCF service that "I quit" but in cases of my client crashed, the connection between my client and WCF service still exists for a time, I simulated 10 crashed time then my app did not work anymore.
And the question is, how to release the connection between WCF and crashed client? because the maxConnections of the server is limited and equal to 10 for example.
Thanks you!
Upvotes: 1
Views: 1878
Reputation: 28728
You could use the InactivityTimeout as Brijesh points out if you are using ReliableSession. Otherwise you should leverage the basic WCF timeouts.
See Timeouts WCF Services for a description of how each timeout is implemented.
Timeouts are often an annoyance for developers, but this is precisely the purpose for which they exist.
Upvotes: 2
Reputation: 2748
you can make use of Inactivity Timeout . Here server will automatically close connection if it doesnot recieve message during specified time frame.
Upvotes: 1
Reputation: 5600
You can make use of using code block in your client:
using(ClientClass client = new ClientClass){
//Call service here
}
This isn't really reliable so you may want to go for try-catch-finally instead. Make sure that client.Abort is called in each of the catch blocks.
Upvotes: -1