C# Windows服务引发MessageSecurityException
我们有一个Windows服务,可以调用WCF服务。正常情况下,它工作正常。但是,当我们重新启动Windows服务时,偶尔会抛出一个C# Windows服务引发MessageSecurityException,c#,wcf,exception,windows-services,wcf-security,C#,Wcf,Exception,Windows Services,Wcf Security,我们有一个Windows服务,可以调用WCF服务。正常情况下,它工作正常。但是,当我们重新启动Windows服务时,偶尔会抛出一个MessageSecurityException,然后所有内容都将抛出,然后再次重复抛出 我们找到的一个解决方案是将AllowedImpersonationLevel设置为“模拟”。但是,我们不使用任何模拟。此外,这是一个随机问题,并不总是可复制的。因此,这一解决方案是无关紧要的 如果有人能对此有所了解,我们将不胜感激 错误消息的堆栈跟踪: 2010-12-24 23
MessageSecurityException
,然后所有内容都将抛出,然后再次重复抛出
我们找到的一个解决方案是将AllowedImpersonationLevel
设置为“模拟”。但是,我们不使用任何模拟。此外,这是一个随机问题,并不总是可复制的。因此,这一解决方案是无关紧要的
如果有人能对此有所了解,我们将不胜感激
错误消息的堆栈跟踪:
2010-12-24 23:18:42581[3]错误
[DataSync]–运行期间发生错误
数据同步[(空)]
System.ServiceModel.Security.MessageSecurityException:
HTTP请求未经授权
客户端身份验证方案
“谈判”。身份验证标头
从服务器接收到的信息为
“协商,NTLM”。->
System.Net.WebException:远程
服务器返回错误:(401)
未经授权。在
System.Net.HttpWebRequest.GetResponse()
在
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
超时)-内部异常堆栈结束
痕迹--
服务器堆栈跟踪:在
System.ServiceModel.Channel.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest
请求,HttpWebResponse响应,
WebException响应异常,
HttpChannel工厂)位于
System.ServiceModel.Channel.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest
请求,HttpWebResponse响应,
HttpChannel工厂,
WebException响应异常,
信道绑定(ChannelBinding)在
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
超时)在
System.ServiceModel.Channels.RequestChannel.Request(消息
消息,TimeSpan超时)位于
System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息
消息,TimeSpan超时)位于
System.ServiceModel.Channels.ServiceChannel.Call(字符串
动作,布尔单向,
ProxyOperationRuntime操作,
对象[]输入,对象[]输出,时间跨度
超时)在
System.ServiceModel.Channels.ServiceChannel.Call(字符串
动作,布尔单向,
ProxyOperationRuntime操作,
对象[]输入,对象[]输出)位于
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
方法调用,ProxyOperationRuntime
操作)在
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
(信息)
这是一个环境问题。计算机无法连接到域控制器,因此无法执行身份验证,这导致了此间歇性问题。是否与IIS中承载的WCF服务相反?如果是,则检查IIS日志中记录的用户失败请求?