2009-11-12 21 views
5

実際のWCFアプリケーションで発生している問題を再現するサンプルWCF​​プロジェクトがあります。 あなたがコードや設定ファイルでタイムアウトセットにAccoding私のサンプルWCF​​アプリケーションhere通信オブジェクトは通信に使用できません。中止されました。

のソースコードをダウンロードすることができ、私はappeningされるかを理解していない:あなたが渡しているよう

**** Server exception : System.ServiceModel.CommunicationObjectAbortedException: 

The communication object, System.ServiceModel.Security.SecuritySessionServerSettings+SecurityReplySessionChannel, cannot be used for communication because it 
has been Aborted. 

    at System.ServiceModel.Channels.CommunicationObject.ThrowIfClosedOrNotOpen() 
    at System.ServiceModel.Security.SecuritySessionServerSettings.ServerSecuritySessionChannel.SecureApplicationMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState) 
    at System.ServiceModel.Security.SecuritySessionServerSettings.SecuritySessionRequestContext.OnReply(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestContextBase.Reply(Message message) 
    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc& rpc) 

**** client exception : : System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: The message could not be processed. This is most likely because the action 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT/Cancel' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding. 
    --- End of inner exception stack trace --- 

Server stack trace: 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.ProcessRequestContext(RequestContext requestContext, TimeSpan timeout, SecurityProtocolCorrelationState correlationState) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.ReceiveInternal(TimeSpan timeout, SecurityProtocolCorrelationState correlationState) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.CloseOutputSession(TimeSpan timeout) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.CloseSession(TimeSpan timeout, Boolean& wasAborted) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnClose(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.OnClose(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) 

Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout) 
    at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout) 
    at System.ServiceModel.ClientBase`1.Close() 
    at System.ServiceModel.ClientBase`1.System.IDisposable.Dispose() 
    at WindowsFormsApplication1.Program.Main() in C:\Users\sdoucet\Documents\Visual Studio 2008\Projects\TestWCFLongExecution\WindowsFormsApplication1\Program.cs:line 25 

答えて

1

が見えます例外はクライアントに戻されます。 WCFは通常の例外を好きではありません。エラーの場合はfaulsやFaultExceptionが必要です。例外が返された後、チャネルはフォールト状態にあり、再び使用することはできません。 FaultExceptionの後、チャネルは引き続き使用可能です。

+0

あなたはそうですが、私のコードでは例外がスローされません。 WCFインフラストラクチャによってスローされます。なぜこの例外がスローされるのか、それを避ける方法を知ることはできません。私は自分のサービスが10分間稼働していることを知っていますが、タイムアウトセットによれば、私は例外を理解していません。 – Sebastien

+2

まず、サービスで完全なトレースを有効にすることです。これは、元の問題が何であるかについて多くの情報を提供します。 – Maurice

6

サービスをホストしているアプリケーションプールが最大ワーカープロセスを1より大きく設定していたため、同様の問題が発生しました。中断または終了の呼び出しに成功するには、そのサービスインスタンスを処理するサービスインスタンスにルーティングする必要があります。元の要求。

+1

これを投稿していただきありがとうございます。お客様のステージング環境でまったく同じ問題が発生しました。彼らの開発者の一人が「Maximum Worker Processes」を5に設定しました。これらの例外が原因です。私たちはwsfederationhttpbindingを使用していて、Security Token Service(STS)も用意していました。例外は、トークンが無効であることを示唆していました。実際、要求は間違った作業者プロセスに向けられていることがありました。 –

+0

同じ問題が発生し、wshttpbindingをメッセージセキュリティとともに使用していました。 Webサービスマシンの前にNetscalarロードバランサを置くことで、より一層厳しい審査が行われました。我々は当初、LBがスティッキセッションを維持していないと考え、LBを取って問題を解決するかどうかを試しました。しかし、それはしませんでした、そして、私たちがMaximum Worker Processes設定が1以上に設定されていることに気づいたとき。 –

2

私はwcfサービスの非同期呼び出しを行ったのと同様の問題がありました。 async_completedメソッドで結果を受け取った後、例外が発生しました。

のInnerException「例外が例外のためのInnerExceptionを確認した結果が無効になって、操作中に発生しました。」:


「それが中止されたため、通信オブジェクトが通信に使用することはできません」

多くの努力の結果、私は解決策を見つけただけで、async_completedメソッドを投げずに例外をキャッチします。 (try/catchを実装しました)。私は正確な問題は何かを理解していませんでしたが、何とか通信チャネルが壊れています。

私はまだ私は、これは正しいアプローチであるが、演算結果と私のシナリオどおりに私はfurtherly何もしておりませんことを確信していないです以下のリンク

http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/23/clean-up-wcf-clients--the-right-way.aspx

から上記approchを試してみました。したがって、例外をキャッチしてサービスを停止しています。

関連する問題