1

I have wrote two multi-threaded windows service. Both connects to the same database. Both are having a WCF service reference.

Say Service "A" is for getting the data from WCF service and writes it down to the connected database. Say Service "B" is for getting the data from connected database and send it to WCF service.

Both starts perfectly and keeps running perfectly for days (though, i have not noted the frequency) But then something occurs and Service "A" status stays on "Running" but it isnt actually running. (I can say this because I am writing log file whenever the service perform something). However Service "B" has never got any problem.

For the resolution, I need to force kill the service using Command Prompt and then restart it. I have checked the event logs but nothing found. RAM is also available so memory is also not an issue.

Farhan Aslam
  • 81
  • 2
  • 13
  • 2
    My best guess here is some sort of deadlock or the service thread waiting for something. But it is impossible to tell without source code. – Thorsten Dittmar Mar 03 '16 at 09:18
  • Thanks, but I cant share code due to organizational limits. – Farhan Aslam Mar 03 '16 at 09:28
  • 2
    Well, then we can't answer due to informational limits :-) My advice: Run the service as application (search how to implement a service that can be both), leave it running in the debugger and see if any exceptions occur. – Thorsten Dittmar Mar 03 '16 at 09:28
  • 1
    Logging global unhandled exceptions (ref : http://stackoverflow.com/questions/1682128/global-exception-handler-for-windows-services) could answer to your question. Is it a periodic service call to the WCF service? – teenboy Mar 03 '16 at 09:46
  • 1
    @Farhan which DB engine are you using? SQL server? – r.pedrosa Mar 03 '16 at 10:02
  • @r.pedrosa yes, 2012 – Farhan Aslam Mar 03 '16 at 10:49
  • @teenboy yes. Frequency is set to every 20 seconds. – Farhan Aslam Mar 03 '16 at 10:50
  • @ThorstenDittmar I have tested it as a console application. and all of the code, even the thread creation resides in try catch. Also, when i restart, it actually does restart. so what sort of exception you are talking about? I mean the data may not have the exception. – Farhan Aslam Mar 03 '16 at 10:52
  • In your question you said you need to force-close the service. That doesn't really match the information that you can normally restart the service... – Thorsten Dittmar Mar 03 '16 at 11:18
  • @ThorstenDittmar Yes, Whenever it hangs, I have to force kill it. and then start it. And when it starts, it behaves normally. It just happened again. I just force kill it and started it. So i dont think there is any problem in the data. as if the data is problmatic it has to occur again and again. Am i clear now? – Farhan Aslam Mar 04 '16 at 10:28
  • @FarhanAslam Did you fix the issue? I have a similar issue. Be great to get your thoughts. – Tez Wingfield Jan 12 '17 at 16:59
  • @TezWingfield Nope. The issue is still there. However for the workaround, I have made a scheduler to restart the service every 1 hour. – Farhan Aslam Apr 30 '17 at 06:11
  • @FarhanAslam Ok, I resolved my issue. (May prove helpful) http://stackoverflow.com/questions/41618324/windows-service-runs-but-stops-processing-after-two-days/41682223#41682223 – Tez Wingfield Apr 30 '17 at 07:38

0 Answers0