Windows 服务抛出 MessageSecurityException

发布于 2024-10-09 03:39:45 字数 1848 浏览 4 评论 0原文

我们有一个进行 WCF 服务调用的 Windows 服务。正常情况下,它工作得很好。但是,偶尔当我们重新启动 Windows 服务时,会抛出 MessageSecurityException ,一切都会陷入困境,此后又会反复抛出。

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

如果有人能够阐明这一点,我们将不胜感激。

错误消息的堆栈跟踪:

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) — 内部异常堆栈结束 追踪——

服务器堆栈跟踪:位于 System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest 请求、HttpWebResponse 响应、 WebException 响应异常, HttpChannelFactory 工厂)位于 System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest 请求、HttpWebResponse 响应、 HttpChannelFactory工厂, WebException 响应异常, ChannelBinding(通道绑定)位于 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)在 System.ServiceModel.Channels.RequestChannel.Request(消息 消息,TimeSpan 超时)于 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息 消息,TimeSpan 超时)于 System.ServiceModel.Channels.ServiceChannel.Call(字符串 动作,布尔单向, ProxyOperation运行时操作, 对象 [] 输入、对象 [] 输出、TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串 动作,布尔单向, ProxyOperation运行时操作, 对象[] ins,对象[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 方法调用、代理操作运行时 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)

We have a Windows Service that makes a WCF service call. Normally, it works fine. However, occasionally when we restart the Windows Service, a MessageSecurityException is thrown and everything goes to toss and it is thrown again repeatedly thereafter.

One solution we found is setting AllowedImpersonationLevel to "Impersonation". However, we don't use any impersonation. Also, it is a random issue and not always reproducible. Hence, this solution would be irrelevant.

Any light that someone can shed on this would be highly appreciated.

The stack trace of the error message:

2010-12-24 23:18:42,581 [3] ERROR
[DataSync] – An error occured during
Data Sync [(null)]
System.ServiceModel.Security.MessageSecurityException:
The HTTP request is unauthorized with
client authentication scheme
‘Negotiate’. The authentication header
received from the server was
‘Negotiate,NTLM’. ->
System.Net.WebException: The remote
server returned an error: (401)
Unauthorized. at
System.Net.HttpWebRequest.GetResponse()
at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
timeout) —End of inner exception stack
trace --

Server stack trace: at
System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest
request, HttpWebResponse response,
WebException responseException,
HttpChannelFactory factory) at
System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest
request, HttpWebResponse response,
HttpChannelFactory factory,
WebException responseException,
ChannelBinding channelBinding) at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
timeout) at
System.ServiceModel.Channels.RequestChannel.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.ServiceChannel.Call(String
action, Boolean oneway,
ProxyOperationRuntime operation,
Object[] ins, Object[] outs) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime
operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人海汹涌 2024-10-16 03:39:45

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

This is an environment Issue. The machine couldn't connect to Domain controller, and hence failed to perform authentication, which caused this intermittent issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文