Windows服务抛出MessageSecurityException

时间:2010-12-27 12:34:10

标签: c# wcf exception windows-services wcf-security

我们有一个Windows服务,可以进行WCF服务调用。通常,它工作正常。但是,偶尔当我们重新启动Windows服务时,会抛出MessageSecurityException并且所有内容都会抛出,之后会再次重复抛出。

我们发现的一个解决方案是将AllowedImpersonationLevel设置为“模拟”。但是,我们不使用任何模仿。此外,这是一个随机问题,并不总是可重现的。因此,这个解决方案无关紧要。

任何有人可以放弃的亮点都将受到高度赞赏。

错误消息的堆栈跟踪:

  

2010-12-24 23:18:42,581 [3]错误   [DataSync] - 期间发生错误   数据同步[(null)]   System.ServiceModel.Security.MessageSecurityException:   HTTP请求未经授权   客户认证方案   '谈判'。身份验证标头   从服务器收到了   “协商,NTLM”。 - >   System.Net.WebException:远程   服务器返回错误:(401)   未经授权。在   System.Net.HttpWebRequest.GetResponse()   在   System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度   timeout) - 内部异常堆栈的结束   追踪 -

     

服务器堆栈跟踪:at   System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest的   请求,HttpWebResponse响应,   WebException responseException,   HttpChannelFactory工厂)   System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest的   请求,HttpWebResponse响应,   HttpChannelFactory工厂,   WebException responseException,   ChannelBinding channelBinding)at   System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度   超时)at   System.ServiceModel.Channels.RequestChannel.Request(消息   消息,TimeSpan超时)at   System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息   消息,TimeSpan超时)at   System.ServiceModel.Channels.ServiceChannel.Call(字符串   动作,布尔单向,   ProxyOperationRuntime操作,   Object [] ins,Object [] outs,TimeSpan   超时)at   System.ServiceModel.Channels.ServiceChannel.Call(字符串   动作,布尔单向,   ProxyOperationRuntime操作,   Object [] ins,Object [] out)at   System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage   methodCall,ProxyOperationRuntime   操作)   System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即时聊天   消息)

1 个答案:

答案 0 :(得分:0)

这是一个环境问题。机器无法连接到域控制器,因此无法执行身份验证,导致此间歇性问题。