私はWCFサービスとそれへのサービス参照を持つアプリケーションを持っています。アプリケーションにはループがあり、各反復でこのwcf Webサービスのメソッドを呼び出しています。
問題は、約 9 回の呼び出しの後、停止することです...そしてPause
、VS のボタンを押すと、呼び出しを行う回線でスタックしていることがわかります。
しばらく待った後、次のTimeoutExceptionがスローされます。
リクエスト チャネルは、00:00:59.9970000 の後に応答を待っている間にタイムアウトになりました。Request への呼び出しに渡されるタイムアウト値を増やすか、Binding の SendTimeout 値を増やします。この操作に割り当てられた時間は、より長いタイムアウトの一部であった可能性があります。
これについて少し調べたところ、アプリケーションで app.config を編集することを含むいくつかの解決策が見つかりました。その抜粋を以下に示します。
<serviceBehaviors>
<behavior name="ThrottlingIssue">
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" />
</behavior>
</serviceBehaviors>
.
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
次に、デバッグを停止してから数分後に、壊滅的な障害が発生したことを知らせるエラー メッセージが表示されます。
この問題を解決するにはどうすればよいですか? 通常の Web サービスを使用していたときは、この問題は発生しませんでした。
参考までに、全体は次のapp.config
とおりです。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ThrottlingIssue">
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDBInteractionGateway" 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"
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>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:28918/DBInteractionGateway.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDBInteractionGateway"
contract="DBInteraction.IDBInteractionGateway" name="WSHttpBinding_IDBInteractionGateway">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
[更新] 解決策:
どうやら、各リクエストの後Close
、接続する必要があります...各リクエストの後に接続を閉じていますが、それは魅力のように機能しています。
まだ理解できないのは、app.config で maxConcurrentCalls と maxConcurrentSessions を 500 に設定しているのに、10 しか作れないということです。(上記の app.config に何か問題があるのかもしれません)
上記の質問 (現在は破線) に対する答えはapp.config
、サービス構成ファイル ( web.config
)ではなく client を編集していたためです。