We are using Topshelf to host a service. Before starting the service, we are making database call to load lot of data. Because of this, while starting the service, we are getting following error:
Start Service failed with return code '[7] ServiceRequestTimeout
We are using following code to start the service:
HostFactory.Run(x =>
{
x.Service<AppService>(s =>
{
s.ConstructUsing(name => new AppService(s_resolver, baseAddress, resolver));
s.WhenStarted(svc => svc.Start());
s.WhenStopped(svc => svc.Stop());
s.WhenShutdown(svc => svc.Shutdown());
});
x.EnableShutdown();
x.RunAsLocalService();
x.StartAutomatically();
x.SetDisplayName("Application Host");
x.SetDescription("Application Host");
});
If I try to launch the service using Visual Studio, service runs fine. But when the service is hosted through Topshelf, I am getting time out error.
I have also tried using hostControl.RequestAdditionalTime(TimeSpan.FromSeconds(300))
but even after adding additional timeout period, I am not able to resolve the issue. Please provide your suggestions.
What the documentation for HostControl.RequestAdditionalTime
fails to state is that you can only ask for a max of 60 or 120 seconds. Otherwise it ignores your request.
It's brilliantly documented absolutely no where that I'm aware of :( If you find it documented some where, please let me know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With