簡體   English   中英

多次異步調用WCF期間發生異常(無法處理該消息…)

[英]Exception during multiple asynchronous calls to WCF (The message could not be processed…)

我從WCF客戶端收到“消息無法處理...”錯誤。 請幫忙,這殺了我。

我有一個測試獲勝的應用程序,它會通過for循環來觸發x個異步調用。 每個異步調用都實例化其自己的WCF代理實例,並使用該代理調用WCF服務。 如果x小於或等於35,則一切都很好。 如果x > 40左右,那么許多調用就可以很好地完成,但是只有少數返回:

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://tempuri.org/IMyService/MakeRequest' 
  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.SecurityRequestSessionChannel.ProcessReply(Message reply, TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
   at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

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

我正在使用客戶端和服務器端證書以及消息安全性。 我不明白為什么它只能運行幾次,然后吐。 它似乎還會在接近迭代結束的調用上引發錯誤。 另外,在我的任何超時都沒有達到之前就發生了此錯誤,在客戶端和服務器端都設置了相同的超時:

<binding name="WSHttpBinding_IMyService" 
         closeTimeout="00:10:00" openTimeout="00:10:00" 
         receiveTimeout="00:10:00" sendTimeout="00:10:00"... />

另外,我正在使用服務限制:

<serviceThrottling 
       maxConcurrentCalls="100" 
       maxConcurrentSessions="100" />

有任何想法嗎?

謝謝馬克。

當您達到一定數量的呼叫數量限制時,您會收到錯誤消息,並且每個呼叫都會創建自己的代理。

因此,該錯誤可能與代理的創建或關閉和清理有關。

您尚未發布代碼,但是您可以通過遵循以下最佳實踐來解決問題並提高代碼性能: http : //blogs.msdn.com/wenlong/archive/2007/10/27/performance WCF客戶端代理創建和最佳實踐的改進.aspx

異步wcf調用的另一個典型問題是,請確保在異步調用返回之前未關閉代理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM