Greetings, I have to following problem. I have a WCF Service which runs under IIS7. Application connects to it and WCF Service makes some requests to DB. I have notice in activity monitor in SQL Server 2005 that after there are exactly 102 active connections, the application pool in IIS7 hangs. After this I can't connect to my WCF Service. Then only IIS7 restart helps. For connection I am using ChannelFactory, it's closed after each request. I've also introduced code like this to be sure that Channel is closed:
catch (FaultException)
{
Factory.Abort();
return null;
}
catch (CommunicationException)
{
Factory.Abort();
return null;
}
catch (TimeoutException)
{
Factory.Abort();
return null;
}
catch (Exception ex)
{
Factory.Abort();
return null;
}
finally
{
Factory.Close();
Factory.Abort();
}
I have also the following behvavior for my service class:
[ServiceBehavior(InstanceContextMode= InstanceContextMode.Single, ConcurrencyMode=ConcurrencyMode.Multiple, AutomaticSessionShutdown=true)]
I have also the following in my service web.config file:
<serviceBehaviors>
<behavior name="Server.Service1Behavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceThrottling maxConcurrentCalls="2147483647"
maxConcurrentSessions="2147483647"
maxConcurrentInstances="2147483647" />
I tried everything. Please help me because user's can't work like this. Why it's happen that after 102 connections to DB application pool hangs? Here is the code that calls on the database
internal SqlConnection CheckIfConnectionOpen()
{
if (_Connection.State != ConnectionState.Open)
{
_Connection.Open();
}
return _Connection;
}
using (SqlCommand cmd = new SqlCommand(query, _Connection))
{
CheckIfConnectionOpen();
//some parameters for sqlcommand here and execute nonQuery or execute reader
}
Can someone please help me with this because I am still looking for a solution