WCF call during OnShutDown () service

I know that there are several other similar questions on this topic, but none of them seem to have an answer, so I thought that we all could do it here.

I have a WCF service running on my servers and am trying to send a status message when the server is closed by overriding "OnShutDown ()".

This can be seen as follows:

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(); } 

This seems to work in about 50% of cases, while for the other 50% I get the following error:

 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 

Does anyone have any idea why this will happen?

+4
source share
2 answers

I ended up saying Dr. Willie. I added to keep in touch with my connection, and now the code will work every time. Basically, windows will not open any new connections during the OnShutDown () method, so if the connection time is over, it will not work normally.

If anyone has an idea around this, this is still surprising, because with this method I will have 2,000 permanent connections to my central server. Shiraz, I tried changing the registry key to provide a longer timeout, but the time did not end with the problem.

+1
source

This may be due to a shutdown timeout. If shutdown takes too long, the process will be killed. It can happen to you.

Try to increase the timeout here:

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Contro l \ WaitToKillServiceTimeout

There may be an event in the event log that says the process was killed.

0
source

Source: https://habr.com/ru/post/1402911/


All Articles