Changing the default timeout for WCF

I have a WCF Duplex service, the requirement is that the client callback must have a timeout of 10 seconds, so my Services web.config file looks like this:

<bindings> <basicHttpBinding> <binding name="simulatorEndpoint" closeTimeout="00:00:10" openTimeout="00:00:10" receiveTimeout="00:00:10" sendTimeout="00:00:10" 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="None"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> <wsDualHttpBinding> <binding name="wsdualEndpoint" closeTimeout="00:00:10" openTimeout="00:00:10" receiveTimeout="00:00:10" sendTimeout="00:00:10" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" clientBaseAddress="http://localhost:1235" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:00:10" /> <security mode="Message"> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /> </security> </binding> </wsDualHttpBinding> </bindings> 

on the client side, the bindings in the app.config file match the same timeout values.

The effects now are that if the client sends a request to the server, the wait time is 10 seconds. But on the other hand, if the service sends a callback to the client, the wait time is 1 minute. This is very strange ... it is obvious that the timeout is set correctly on the client side ... but not on the service ... How can I change the timeout on the service?

PS: I am using Visual Studio 2010 and its debugging mode with an approved ASP.NET Development Server 10.0.0.0

+4
source share
2 answers

A brief overview of interception timeouts ...

Client side:

  • SendTimeout is used to initialize an OperationTimeout, which controls all communication to send a message (including receiving a response message in case of a response request). This timeout also applies when sending response messages from the CallbackContract method.
  • OpenTimeout and CloseTimeout are used when opening and closing channels (in the absence of an explicit timeout value).
  • ReceiveTimeout is not used.

Server side:

  • Postpone, open and close the timeout, as on the client (for callbacks).
  • ReceiveTimeout is used by the ServiceFramework layer to initialize the session timeout.

[edit: code] Also try adding this to your service configuration

 <behaviors> <endpointBehaviors> <behavior name="MyCallbackBehavior"> <callbackTimeouts transactionTimeout="00:00:10"/> </behavior> </endpointBehaviors> <behaviors> 

then add behavior to the endpoint

 <endpoint behaviorConfiguration="MyCallbackBehavior" /> 
+4
source

Ok, I found a mistake ...

I did the binding with the correct setting using

  <wsDualHttpBinding> <binding name="wsdualEndpoint" closeTimeout="00:00:10" openTimeout="00:00:10" receiveTimeout="00:00:10" sendTimeout="00:00:10" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" clientBaseAddress="http://localhost:1235" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:00:10" /> <security mode="Message"> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /> </security> </binding> </wsDualHttpBinding> 

but the key was that this was my endpoint declaration:

  <endpoint address="dual" binding="wsDualHttpBinding" name="wsdualEndpoint" contract="INotificationService"/> 

since my assumption was that he would select the above specific binding configurations and use them for my endpoint, but that was wrong, I should add bindingConfiguration = "CONFIGURATION NAME" to the endpoint declaration.

Therefore, for your information, my working configuration is as follows:

  <wsDualHttpBinding> <binding name="MywsdualEndpoint" sendTimeout="00:00:05" 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"/> <security mode="Message"> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /> </security> </binding> </wsDualHttpBinding> 

and the correct endpoint declaration:

  <endpoint address="dual" binding="wsDualHttpBinding" bindingConfiguration="MywsdualEndpoint" contract="INotificationService"/> 
+3
source

Source: https://habr.com/ru/post/1300861/


All Articles