c# – 服务期间的WCF呼叫OnShutDown()
发布时间:2020-12-15 21:32:02 所属栏目:百科 来源:网络整理
导读:我知道在这个主题上还有一些其他类似的问题,但是它们似乎都没有答案,所以我想我们都可以在这里哈希. 我在我的服务器上运行了WCF服务,并且我试图通过覆盖“OnShutDown()”来关闭服务器时发送状态消息. 这可以看作如下: protected override void OnShutdown()
我知道在这个主题上还有一些其他类似的问题,但是它们似乎都没有答案,所以我想我们都可以在这里哈希.
我在我的服务器上运行了WCF服务,并且我试图通过覆盖“OnShutDown()”来关闭服务器时发送状态消息. 这可以看作如下: protected override void OnShutdown() { try { client.updateInvStatus(machineName,"Client Host Has Shutdown"); } catch (Exception ex) { EH.writeToErrorLog("||OnShutdown||Error Shutting Down System rn" + 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:UsersdaladdDocumentsCSAscertainAscertainAscertainService ReferencesAscertainAgentReference.cs:line 209 at Ascertain.Service1.OnShutdown() in "FILE LOCATION REMOVED"Service1.cs:line224 有没有人有任何想法为什么会发生这种情况? 解决方法
我最后跟着Dr.Wily说了些什么.我为我的连接添加了一个保持活动状态,现在代码每次都会工作.基本上,Windows在OnShutDown()方法期间不会打开任何新连接,因此如果连接超时,它将无法正常工作.
如果有人对此有一个想法仍然会很惊人,因为使用这种方法我将有2000个持久连接到我的中央服务器. Shiraz,我确实尝试更改注册表项以允许更长的超时,但时间并没有最终成为一个问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |