Click here to Skip to main content
15,894,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a c# win project that uses a wcf service to connect the SQL SERVER 2008R2.
When the service calls to a long stored procedure, after ~10 minutes the client throw this exception:

C#
Error in mscorlib Message: The communication object, System.ServiceModel.Security.SecuritySessionClientSettings`1+ClientSecurityDuplexSession
Channel[System.ServiceModel.Channels.IDuplexSessionChannel]


I looked on the SQL profiler and saw that the SQL server is continuing run the SP and the error was just in the client side.

Do you have a suggestion why it happened?

(It occurred just on the production, in the DEV the service and the application in the same server and it doesn't occurred)

Thanks,
Efrat

EDIT:

I have a contract that use [ServiceContract] and [OperationContract].
The service class implement the contract

Client App.Config

XML
<endpoint address="net.tcp://localhost/Services/Service.svc"
       binding="netTcpBinding" bindingConfiguration="NetTcpBinding" behaviorConfiguration="normal"
       contract="Services.Contracts.IService" name="IService">
     <identity>

Server Web.Config
XML
<service name="Services.Service" behaviorConfiguration="Service1Behavior">
       <endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding.WindowsAuth" contract=".Services.Contracts.IService" behaviorConfiguration="epNormal">
       </endpoint>
       <host>
         <baseAddresses>
           <add baseAddress="net.tcp://localhost/Services/" />
         </baseAddresses>
       </host>
     </service>


What I have tried:

I tried to restore the bug in DEV so I set the idle in the IIS to less than the SP run, after this time there was an exception in the client but also the SQL SERVER stopped run the SP.
Posted
Updated 14-Feb-16 23:26pm
v3

1 solution

Add following code when you are calling WCF service:
C#
using(WCFServiceClient client = new WCFServiceClient ())
{ 
    // 15 minutes 30 seconds
    client.Endpoint.Binding.SendTimeout = new TimeSpan(0, 15, 30); 
}

or
For a client, you would want to adjust the sendTimeout attribute of a binding element. For a service, you would want to adjust the receiveTimeout attribute of a binding element.
XML
<system.serviceModel>
  <bindings>
    <netTcpBinding>
      <binding name="longTimeoutBinding"
        receiveTimeout="00:10:00" sendTimeout="00:10:00">
        <security mode="None"/>
      </binding>
    </netTcpBinding>
  </bindings>

receiveTimeout - It includes receiving a reply message for a request/reply service operation. This timeout also applies when sending reply messages from a callback contract method.

sendTimeout - Gets or sets the interval of time that a connection can remain inactive, during which no application messages are received, before it is dropped.

It is in Hour:Minute:Second format.

Secondly you need to improve performance of execution of StoredProcedure. It is not good to execute a stored proc as 10 minutes. So just see execution plan and add find out where it is taking time. You can add some non-clustered index to tables or optimize your select query.

SQL Profiler and SQL Tuning Advisor[^]
 
Share this answer
 
v3
Comments
Member 8092498 15-Feb-16 5:00am    
I don't use this method to call WCF.
The Web Service called using Operation Contract.
I can Change configuration file but the config in dev and prod is the same.
The SP take more than a hour because it has heavy calculations.
[no name] 15-Feb-16 5:14am    
Provide the relevant code how you are calling WCF service.

You need to optimize your SP. Nobody will wait 1hr for your complex calculation.
Member 8092498 15-Feb-16 5:26am    
I Edited the question with the relevant code
[no name] 15-Feb-16 5:39am    
Updated the answer..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900