我从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" />
有什么想法吗?
谢谢,Mark。
答案 0 :(得分:0)
当您达到拨打电话的某个限制时,您会收到错误,并且每次通话都会创建自己的代理。
因此,错误可能与代理的创建或关闭和清理有关。
您尚未发布代码,但您可以通过遵循以下最佳做法来解决问题并提高代码性能:http://blogs.msdn.com/wenlong/archive/2007/10/27/performance-improvement-of-wcf-client-proxy-creation-and-best-practices.aspx
异步wcf调用的另一个典型问题是确保在异步调用返回之前代理未关闭。