简体   繁体   English

调试Windows服务超时

[英]Debug Windows Service timeout

I have a windows service that creates an instance of UdpClient class and listen for incoming request. 我有一个Windows服务,它创建一个UdpClient类的实例并监听传入的请求。 I have a helper class to run it as a console application. 我有一个帮助程序类来将其作为控制台应用程序运行。 When i run it as a console program, it runs fine and receive connections normally. 当我将它作为控制台程序运行时,它运行正常并正常接收连接。 When deployed as a Windows Service using "installutil MyService" and start it, I get the following error: "Error 1053: the service did not respond to the start or control request in a timely fashion." 当使用“installutil MyService”部署为Windows服务并启动它时,我收到以下错误:“错误1053:服务未及时响应启动或控制请求。” The service don't even start, so I can't place a breakpoint in code. 该服务甚至没有启动,所以我不能在代码中放置断点。 Any suggestion about how to debug this or where to look? 关于如何调试这个或在哪里看的任何建议? Thanks. 谢谢。

Your Start() method is taking too long to do whatever it does when the service starts - if memory serves you have something like 15 seconds to kick-off whatever tasks the service is supposed to perform (on separate threads for long-running or continuous activities) and you must then allow the startup method to end so that the Service Controller recognises that the service has finished starting. 你的Start()方法花费太长时间来做它在服务启动时做的任何事情 - 如果内存服务你有15秒的时间来启动服务应该执行的任何任务(在长时间运行或连续的单独线程上)然后,您必须允许启动方法结束,以便服务控制器识别该服务已完成启动。

You didn't post any code, but my assumption would be that you're listening for UDP traffic synchronously - so the startup method just sits there waiting for UDP messages and never ends. 您没有发布任何代码,但我的假设是您正在同步监听UDP流量 - 因此启动方法只是在那里等待UDP消息并且永远不会结束。 Put the UDP listener into its own thread, start that thread, and then let the startup method end. 将UDP侦听器放入其自己的线程,启动该线程,然后让启动方法结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM