Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, September 10, 2018 8:12 PM
We have a service built on C# that is a part of our application. The service has the following dependencies:
- DNS Client
- Server
- TCP/IP Protocol Driver
The service is define like this:
public partial class MyService : ServiceBase{... protected override void OnStart(string[] args) { ... }}
Then we run it like this:
private static void Main(string[] args)
{ .... ServiceBase.Run(new MyService());
This is pretty standard way to run services in C#. In most cases the service starts OK, but in some situations, after a system restart, the service does not start and we see the following error in the System log:
A timeout was reached (30000 milliseconds) while waiting for the Accurate ID Service service to connect.
The problem here is that there is no sign of any attempt from the system to actually start the service. As soon as the above "Main()" function is called, we write a message into our log file and when the service does not start, we do not see this message. This suggests that the problem may be system related because Windows Operating System does not call the executable for some reasons. Our support guys told us that this is probably happening when Windows installs automatic updates. This is reasonable because updates take some time and maybe our service times out before the system gets to the point when it can call the service, because it was busy installing updates.
It looks like this problem became more often recently, which might point to some windows system update that is causing this issue.
All replies (11)
Monday, September 10, 2018 11:56 PM
Perhaps trying RequestAdditionalTime method.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
Tuesday, September 11, 2018 12:48 AM
This is a solution multiplied by many times that pops out as a first line in google search. I was trying to explain my problem as clear as possible, but I think I failed. We DO have this line. But it does not matter because Windows OS DOES NOT CALL OnStart(). There is a log record that I create as soon as the this function is called. Every time the service starts normally, I can see this record. But in the situation when we have the startup problem Windows does not actually call our service. It simply puts "A timeout was reached (30000 milliseconds) while waiting for the ... Service service to connect." in system log, but I believe it does not call our service.
Tuesday, September 11, 2018 1:11 AM
I hadn't checked Google and you never indicated that you were aware of that method.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
Tuesday, September 11, 2018 7:02 AM
Hi Aleksey Malyshev,
Thank you for posting here.
>> In most cases the service starts OK, but in some situations, after a system restart, the service does not start and we see the following error in the System log:
I am not sure the update cause the error. Do you have some code to end your service? If yes, you could try to get the status of your system. When you system shut down, close your service. You could set the service to start at boot as well.
Best Regards,
Wendy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Tuesday, September 11, 2018 12:38 PM
I am sorry, I don't understand anything in your response. What status should I get? Isn't it so that Windows Operating System should call "protected override void OnStop()" to stop the service? Why do I need to do it manually? And what does it mean "set the service to start at boot"? Does "Startup Type" "Automatic" not mean that the service will be started at boot time? How do start at boot and start after a reboot differ?
Tuesday, September 11, 2018 1:52 PM
The lifetime of a service is very well defined by Windows. It is unclear to me where in the lifetime you're seeing your error, if at all.
Service Main is called when the service process is started. This is generally when the service starts but if you are hosting multiple services then it'll get called when the first service is started. Shortly after that call you'll get the OnStart call for the specific service being started. The service has a fixed amount of time to start before the SCM will assume it is non-responsive and report an error. The error you get doesn't line up with the one you posted so it seems unlikely.
1) Given your logging you have configured, you're saying your Main method is never called? If so then your service process isn't getting started either. Go to the event log and look in the System logs to see if Windows is recording your service starting or stopping at all.
2) In your timeout message it mentions the Accurate ID service. Is that your service? Is your service configured for AutoStart or Delay (AutoStart)?
3) You mentioned you have dependencies. Does that mean your installer has configured our service to depend on those other services as well? Windows starts services based upon group and dependencies so until those services come online your service wouldn't attempt to start.
4) Does the service start correctly if you start it manually? Does this failure occur on every reboot or just certain ones? Enable boot logging to see what is going on in the system at the time of the failure if possible.
Michael Taylor http://www.michaeltaylorp3.net
Tuesday, September 11, 2018 9:13 PM
Just a general note, I was trying to reply to this thread from the same browser where I started it yesterday and was not able to - all links look OK, but when I click any of them, like "Reply", "Quote", etc., nothing happens. I was trying to reload the page multiple times, did logout then login, opened the page in a new tab - no result. I had to use a different browser. Not sure what problem is.
Tuesday, September 11, 2018 9:27 PM
1) Not quite - I meant that the Main method is never called when the system reports that error above. When I went to the System logs I can see the error: "A timeout was reached (30000 milliseconds) while waiting for the <MyService> Service service to connect." And you are absolutely correct in this case the process does not start.
2) Yes, this is my service. I was trying to keep the name private, but accidentally left it here. So now I guess you know who I work for. Anyway, it is configured for AutoStart.
3) Yes, These are dependencies that the installer configured. I copied them from the service "Dependencies" tab in the service information window. Previously we did not have dependencies set up in the installer, but I added them thinking that the service cannot start because other services did not start, but it did not help.
4) Yes, when the service is started manually it always starts correctly. After a reboot in most cases (say ~99%) the service automatically starts correctly. Only in rare cases the service does not start. We think that those cases are related to the fact that Windows Operating System was busy installing updates and did not run our service on time.
I tried boot logging, but not sure how it can help. I can only see loaded drivers in the boot log. No services mentioned.
Tuesday, September 11, 2018 9:58 PM
Hmm. It could be a stall while WU runs but I don't know that I've ever seen this cause any issues with services. A WU would likely update before the SCM tries to start most services and until it tries to start your service then the timer doesn't start. It's almost like Windows is trying to start your service process and that is timing out which would lean toward an issue on the system itself.
I wonder about things like anti-virus or optimization software that may stall file requests while they process things. These tend to slow things down after an update because they have to reprocess changed files.
Have you tried the workaround given in this KB article?
For boot logging I should have been more specific. I meant using something like DebugView with the Log Boot and kernel options set so you might be able to see something in the logs.
Michael Taylor http://www.michaeltaylorp3.net
Wednesday, September 12, 2018 1:15 AM
Yes, that's what I think it is. The system may be too busy to start the service but starts counting from the point in time when it tries to start it, e.g. - runs some low-priority thread that never actually starts. In some cases along with our service, I've seen other, less critical one, that system also reported as "failed to start within 30 seconds". If I remember correctly it was some Intel service.
And yes, we are testing the "ServicesPipeTimeout" option. I'll get back to it in a few days when we hear from our support guys.
Wednesday, September 12, 2018 9:12 AM | 1 vote
I had the same issue. Sometimes, after restart, SCM did not made a call to my service (I have also added event log to main and onstart methods). There were no useful information in EventViewer\Application Logs. Only in EventViewer\System logs that same timeout exception. Beside my service, i could see that also Windows Defender and TeamViewer had the same error on startup (and probably sometimes some other services, but i haven't payed attention regarding other services). After boot, i could always start service manually without any kind of problem.
For now, it occurred only on computers with poor configuration with installed Windows 10 Pro, Version 1803.
It looks like that after adding ServicesPipeTimeout, that problem stopped occurring.
I could propose this as fix to my clients, but I would like to deliver it with a link to microsoft bug to have some valid explanation for customers why should i made them add/update information in their registries.
If you find out something more, please write me.
Did anybody else have same problem?