c# – 服务期间的WCF呼叫OnShutDown()
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – 服务期间的WCF呼叫OnShutDown(),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2774字,纯文字阅读大概需要4分钟。
内容图文
![c# – 服务期间的WCF呼叫OnShutDown()](/upload/InfoBanner/zyjiaocheng/770/66964a9ac603436f80728702cc53204d.jpg)
我知道在这个主题上还有一些其他类似的问题,但是它们似乎都没有答案,所以我想我们都可以在这里哈希.
我在我的服务器上运行了WCF服务,并且我试图通过覆盖“OnShutDown()”来关闭服务器时发送状态消息.
这可以看作如下:
protected override void OnShutdown()
{
try
{
client.updateInvStatus(machineName, "Client Host Has Shutdown");
}
catch (Exception ex)
{
EH.writeToErrorLog("||OnShutdown||Error Shutting Down System \r\n" + ex);
}
base.OnShutdown();
}
这似乎在50%的时间内起作用,另外50%我得到以下错误:
System.ServiceModel.Security.SecurityNegotiationException: Could not establish secure channel for SSL/TLS with authority '"ENDPOINT ADDRESS REMOVED'. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitF orReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebExceptoon webException, HttpWebRequest request, HttpAbortReason abortReason)
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.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 Ascertain.AscertainAgent.IService.updateInvStatus(String hostNM, String invValue)
at Ascertain.AscertainAgent.ServiceClient.updateInvStatus(String hostNM, String invValue) in C:\Users\daladd\Documents\CS\Ascertain\Ascertain\Ascertain\Service References\AscertainAgent\Reference.cs:line 209
at Ascertain.Service1.OnShutdown() in "FILE LOCATION REMOVED"\Service1.cs:line224
有没有人有任何想法为什么会发生这种情况?
解决方法:
我最后跟着Dr.Wily说了些什么.我为我的连接添加了一个保持活动状态,现在代码每次都会工作.基本上,Windows在OnShutDown()方法期间不会打开任何新连接,因此如果连接超时,它将无法正常工作.
如果有人对此有一个想法仍然会很惊人,因为使用这种方法我将有2000个持久连接到我的中央服务器. Shiraz,我确实尝试更改注册表项以允许更长的超时,但时间并没有最终成为一个问题.
内容总结
以上是互联网集市为您收集整理的c# – 服务期间的WCF呼叫OnShutDown()全部内容,希望文章能够帮你解决c# – 服务期间的WCF呼叫OnShutDown()所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。