Session timeout differences - c#

I am doing some support on a pretty big project. My assignment is to change the session timeout to something longer then what it is now. Right now they are logged off after about 10 min or so. I have found a lot of different things that it could be and i need some help figuring out what they all do.
first of all i got this one:
<sessionState mode="InProc" timeout="240" cookieless="UseCookies" />
This is triggerd after 240 mins so it can't be this one.
Then i got this:
<binding name="WSHttpBinding_IFootprintService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:00:01" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:00:01" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
</binding>
<binding name="AdministrationEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:00:01" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:00:01" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
</binding>
<binding name="ProductionEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:00:01" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:00:01" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
In that code there is a lot of different things that i could be. And i just can't figure out what the difference is between closeTimeout, openTimeout, receiveTimeout, sendTimeout, inactivitytimeout and sessionstate timeout?

Borrowing the response by #marc_s in this question
The most important is the sendTimeout, which says how long the client
will wait for a response from your WCF service. You can specify
hours:minutes:seconds in your settings - in my sample, I set the
timeout to 25 minutes.
The openTimeout as the name implies is the amount of time you're
willing to wait when you open the connection to your WCF service.
Similarly, the closeTimeout is the amount of time when you close the
connection (dispose the client proxy) that you'll wait before an
exception is thrown.
The receiveTimeout is a bit like a mirror for the sendTimeout - while
the sendTimeout is the amount of time you'll wait for a response from
the server, the receiveTimeout is the amount of time you'll give you
client to receive and process the response from the server.
In case you're send back and forth "normal" messages, both can be
pretty short - especially the receiveTimeout, since receiving a SOAP
message, decrypting, checking and deserializing it should take almost
no time. The story is different with streaming - in that case, you
might need more time on the client to actually complete the "download"
of the stream you get back from the server.
Hope it helps,

Hope this site helps you a bit http://msdn.microsoft.com/en-us/library/hh924831(v=vs.110).aspx
Quick summary about timeouts:
On the client side:
SendTimeout – used to initialize the OperationTimeout, which governs the whole process of sending a message, including receiving a reply message for a request/reply service operation. This timeout also applies when sending reply messages from a callback contract method.
OpenTimeout – used when opening channels when no explicit timeout value is specified
CloseTimeout – used when closing channels when no explicit timeout value is specified
ReceiveTimeout – is not used Client-side Timeouts
On the service side:
SendTimeout, OpentTimeout, CloseTimeout are the same as on the client
ReceiveTimeout – used by the Service Framework Layer to initialize the session-idle timeout which controls how long a session can be idle before timing out.
Also see this post about WCF session timeout WCF Session Timeout

Related

WCF throws error intermittently for the first time whenever I access if after a long time

WCF throws below error intermittently whenever I access the service for the first time in day or after long time.
"The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error."
Otherwise, it works fine in every case. I am not able to understand why this error occurs?
P.s : I have referred many threads and tried config changes,checked proxy mismatching, but none of them worked for me.
please guide me otherwise I have to put retry option in the service
Update
Client config
<endpoint address="xxxxx" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="IService" name="BasicEndPoint" />
<binding name="Binding1" maxReceivedMessageSize="99999999"
closeTimeout="00:05:00" openTimeout="00:05:00"
sendTimeout="00:05:00" receiveTimeout="00:05:00" >
<readerQuotas maxStringContentLength="99999999" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<binding name="BasicEndPoint" closeTimeout="00:03:00" openTimeout="00:03:00"
receiveTimeout="00:10:00" sendTimeout="00:03:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
Service config:
<binding name="Binding1" maxReceivedMessageSize="99999999">
<readerQuotas maxStringContentLength="99999999" />
<security mode="None">
</security>
</binding>
Okey, I have had a lot of strange error messages during the time I have been working with WCF services. What I learned from that is that they do not alwats make that much sense.
When that said, when you describe yur problem, it sounds like one issue I had with one of the WCF services I have worked with that used named pipes. That was a problem related to the activation. Then I had to refresh the service address in the browser then it worked fine. To solve that it was a permission issue.
Anouther thing that have been gining me error messages is that the namespace and contract to the service is correct in the web.config.
When I was googling your error message, there seems like some people get this have issues with enum in the service. I do not think that's your issue, but maybe... WCF catches exception " The server did not provide a meaningful reply.."

WCF service timing out before the specified timeout value passes

I have a WCF service which is called by my console application. The console app is setup as a scheduled task in windows that runs once a day. The console app calls the WCF service operation and the operation takes long and the error received at the console app is that
The request channel timed out while waiting for a reply after 11:59:59.9050000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout
I have set up all 4 timeouts at 12 hours but still it timesout within the first minute of executing and I receive the above error about timeout which says its been waiting for 11:59:59.9050000 but I know it didnt wait for more than 1 minute. Does anyone know why?
Here are my binding properties in my app.config:
<binding name="HoldbackEndpoint" closeTimeout="12:00:00" openTimeout="12:00:00"
receiveTimeout="12:00:00" sendTimeout="12:00:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<readerQuotas maxDepth="999" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>

The caller was not authenticated by the service wsDualHttpBinding

I have searched and tried to apply the solution given on the other posts, but i cant solve my problem yet.
I have to use wsDualHttpBinding for duplex connection.
When I try to run my client on the same machine with the WCF server, it can run perfectly, but when i move the client to other machine on the same domain, it return an error "The caller was not authenticated by the service"
here is the app.config on my client
<wsDualHttpBinding>
<binding name="duplexendpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
</security>
</binding>
</wsDualHttpBinding>
then i tried to give the credential via the code :
client.ClientCredentials.Windows.ClientCredential.UserName = "serverusername";
client.ClientCredentials.Windows.ClientCredential.Password = "serverpassword";
client.ClientCredentials.Windows.ClientCredential.Domain = "serverdomain";
and it give an error "Client is unable to finish the security negotiation within the configured timeout"
is there any way to solve my problem? thanks.
oke I have found the solution for my problem, i have to turn off the firewall from the client machine.

Intermitent WCF service timeout exception

We have a WCF service hosted in Windows service and a single non-threaded client accessing the service. The service is performing data access to a SQL Server 2008 database. Intermitently the following exception occurs on the client side:
System.TimeoutException: The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
I am aware that this error can be a bit of a catch all for WCF problems but I am certain that the error is not occuring because the operation takes over a minute (I have trippled the timeout and it still occurs).
The problem has occurred on multiple endpoints and occurs on the call to the client proxy. I logged to a text file the various points the service reaches when the crash occurs and see that the return statement from the service is reached.
The client and service have been in use in some form for over two years and this problem appears to have occurred only recently and without any obivious changes in areas significant to the service (although both of these statements are danagerous to rely on when debugging a problem).
Any advice, thoughts or suggestions to investigate would be appreciated.
Here is the service binding:
<binding name="WSHttpBinding_IDataService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
and here is the client binding:
<binding name="WSHttpBinding_IAssessmentDataAccessContract"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="">
<extendedProtectionPolicy policyEnforcement="Never"/>
</transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true"/>
</security>
</binding>
I had a similar issue with a service that connected to an Oracle database. The culprit took me some time to find, but the first step I would take would be to enable tracing on both the server and the client. Here is the MSDN doc on how to do that. Jump to the recomended settings for tracing in production environment
What it sounds like is that you have a value TYPE in the database that WCF does not know how to serialize, or it is not included in the KnownTypes attribute of your ServiceContract. When I ran into this issue, it was very similar, but I needed to dig through the traces to find that something was not being serialized (or deserialized) properly on the call. My problem was in returning a dataset instead of a specific value, it was harder to find exactly what data was the culprit.
If you do not have a custom error handler, WCF is prone to locking up on an exception and your client with get a "timeout".
when the crash occurs and see that the return statement from the service is reached.
That helps but doesn't mean the server side isn't causing/adding to the problem.
Is it possible your method returns a very large payload and it takes too long to download or exceeds the maximum size of the WCF bindings?
Now, the reason you might not have seen this until now is NOW you have 2 years worth of data so you may be returning more stuff than you did initally. Just a guess.
eg
public string GetStuff()
{
return //large payload
}
what do you bindings look like on both ends? Wwhat is the value of maxStringContentLength ?

How to tell if WCF service client proxy has timed out

I have a WCF service using wsHttpBinding with message encryption. I use the same service reference unless it has become faulted, in which case I create a new one. I'm running in to an issue where the session has timed out and the service has closed its end, but the client application still has the CommunicationState as Opened.
How can I tell in ClientBase if the connection has timed out? I want in my client application to create a new service proxy if the current one has timed out.
Below is my client-side binding:
<wsHttpBinding>
<binding name="wsHttpBindingWithAuthClient" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="20000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
Why don't you just wrap all of your service calls in a try/catch, and in the catch block of the specific exception type of server connection timeout, recreate the proxy.
try
{
serviceProxyGlobal.Method()
}
catch(WhateverServerTimeoutException ex)
{
serviceProxyGlobal = new ServiceProxy();
//retry maybe?
}
catch(Exception ex)
{
logException(ex);
}
Please consider accessing that shared web service reference using a simple getter, where you basically try to "ping" your web service just before returning reference to it (that "ping" method should be really simple, like Boolean Ping() { return true; }) If it throws exception (here you have to cater for all possible scenarios), simply handle it, suppress it (if it's an exception you can identify and which you expected) and create new shared connection.
Alternatively you can design a method pinging your web service each [web service timeout in minutes] / 2 minutes in a background thread.

Categories

Resources