4

私はここに WCF Duplex Service を持っています。要件は、クライアントへのコールバックが 10 秒のタイムアウトを持つ必要があることです。そのため、サービスの web.config ファイルは次のようになります。

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

クライアント側では、app.config ファイルのバインディングは同じで、タイムアウト値も同じです。

クライアントがサーバーにリクエストを送信すると、タイムアウトは 10 秒になります。一方、サービスがクライアントにコールバックを送信する場合、タイムアウトは 1 分です。それは非常に奇妙です...明らかに、タイムアウトはクライアント側で正しく設定されています..しかし、サービスではありません...サービスのタイムアウトを変更するにはどうすればよいですか?

PS: 私は Visual Studio 2010 を使用しており、適切な ASP.NET Development Server 10.0.0.0 でデバッグ モードを使用しています。

4

2 に答える 2

4

バインディング タイムアウトの概要...

クライアント側:

  • SendTimeout は、メッセージを送信するための対話全体 (要求と応答の場合の応答メッセージの受信を含む) を管理する OperationTimeout を初期化するために使用されます。このタイムアウトは、CallbackContract メソッドから応答メッセージを送信するときにも適用されます。
  • OpenTimeout と CloseTimeout は、チャネルを開いたり閉じたりするときに使用されます (明示的なタイムアウト値が渡されない場合)。
  • ReceiveTimeout は使用されません。

サーバ側:

  • 送信、オープン、およびクローズのタイムアウトは、クライアントと同じです (コールバック用)。
  • ReceiveTimeout は、セッション アイドル タイムアウトを初期化するために ServiceFramework レイヤーによって使用されます。

[編集: いくつかのコード] また、これをサービス構成に追加してみてください

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

次に、動作をエンドポイントに追加します

<endpoint behaviorConfiguration="MyCallbackBehavior" />
于 2010-02-11T09:25:09.837 に答える
3

わかりました、私は間違いを見つけました...

私はバインディング構成を正しく行いました

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

しかし、手がかりは、これがエンドポイントの私の宣言であるということでした:

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

私の仮定は、彼が上記で定義されたバインディング構成をフェッチし、それらをエンドポイントに使用することでしたが、それは間違っていたので、エンドポイント宣言に bindingConfiguration="THE NAME of THE CONFIGURATION" を追加する必要があります。

したがって、参考までに、私の作業構成は次のようになります。

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

正しいエンドポイント宣言は次のとおりです。

        <endpoint address="dual" binding="wsDualHttpBinding" bindingConfiguration="MywsdualEndpoint" contract="INotificationService"/>
于 2010-02-11T12:40:51.500 に答える