views:

1236

answers:

2

Hi,

I have here a WCF Duplex Service, the requierement is that the Callback to the client should have a timeout of 10 seconds, therefor my web.config file of the Service 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 are the same with the same timeout values.

The effects are now that if the client sends a request to the server the Timeout is 10seconds. But on the other side if the service sends a callback to the client the timeout is 1minute. Thats very strange...obviously the timeout is correctly set 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 the debug mode of it with the approbiate ASP.NET Development Server 10.0.0.0

A: 

Brief summary of binding timeouts...

Client side:

  • SendTimeout is used to initialize the OperationTimeout, which governs the whole interaction for sending a message (including receiving a reply message in a request-reply case). This timeout also applies when sending reply messages from a CallbackContract method.
  • OpenTimeout and CloseTimeout are used when opening and closing channels (when no explicit timeout value is passed).
  • ReceiveTimeout is not used.

Server side:

  • Send, Open, and Close Timeout same as on client (for Callbacks).
  • ReceiveTimeout is used by ServiceFramework layer to initialize the session-idle timeout.

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

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

then add the behavior to your endpoint

<endpoint behaviorConfiguration="MyCallbackBehavior" />
Neil
When i set this behaviour the client gets stucked when he tries to call a method on the service the first time and the other timeouts (as you can see in the code snippet) are already set. Is it possible that somehow WCF ignores my settings and sets all the TimeOut-values back to default?Is there a way to set the Service timeouts programmatically i read a thread about here, but the solutions wheren't really attractive to meBut am I right in my assumption that when the service callbacks to the client..this timeout-duration has nothing to do with the timeout-settings on the client-side right?
Hannes S
A: 

Ok i found the mistake...

i did the bindingConfiguration right with

        <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 clue was that this was my declaration of the endpoint:

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

because my assumption was that he would fetch the above defined binding-configurations and use them for my endpoint, but that was wrong, i have to add bindingConfiguration="THE NAME of THE CONFIGURATION" to the endpoint-declaration.

Therefor, just for your information my working configuration looks like this:

      <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 is:

        <endpoint address="dual" binding="wsDualHttpBinding" bindingConfiguration="MywsdualEndpoint" contract="INotificationService"/>
Hannes S