.NET 4.0 中的 WCF 服务进入“睡眠”状态但 ping 会将其唤醒
大家早上好。
我对 WCF 有点陌生,我们创建了一个新的 WCF 服务。此服务使用 net.msmq 绑定来传输和接收来自另一个 WCF 服务的消息。这一切都很棒。但是,当我们将该服务部署到服务器时,这个新的 WCF 服务就会“休眠”。我会解释一下。
我完全理解 WCF 服务不像 Windows 服务那样运行。我的意思是,一旦我们对服务执行 ping 操作,它就会正常运行几分钟。它按其应有的方式监视 MSMQ 队列并按其应有的方式处理消息。发送和接收工作都很好。如果传入数据出现间歇,该服务似乎就会停止监听。它将保持这种状态,直到我们通过访问我们必须放置的 HTTP 服务公开的 URL 来 ping 服务。
我们并没有将其构建为 RESTful 服务,因此我认为这不会成为问题。有人有什么想法吗?
谢谢吉姆
·埃文斯,MCAD
Good Morning, everyone.
I am somewhat new to WCF and we have created a new WCF service. This service uses net.msmq bindings to transfer and receive messages from another WCF service. This all works GREAT. However, when we deploy the service to our servers, this new WCF service "falls asleep". I'll explain.
I completely understand that the WCF Service doesn't run like a Windows service. What I mean is that, once we ping the service, it'll run fine for a few minutes. It monitors the MSMQ queues that it's supposed to and processes the messages just like it should. Send and receive work just fine. If there is a lull in the incoming data, the service just seems to stop listening. It will stay in this state until we ping the service by going to the URL exposed by the HTTP service that we had to put in place.
We didn't build this to be a RESTful service, so I wouldn't expect that to be the issue. Anyone have any ideas?
Thanks,
Jim Evans, MCAD
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果该服务在 IIS 下运行,并且没有针对该服务的 http 请求,则该服务可能会出现回收超时。目前尚不清楚其他服务的监视是如何完成的,但如果没有外部请求,IIS 将使服务进入睡眠状态,因此也许更改受监视的服务,以便它向监视服务发送通知。
如果您有自托管 WCF 服务,请丢弃第一段,自托管 WCF 服务不受 IIS 影响,除非您将其关闭,否则不应进入睡眠状态。
If the service runs under IIS it is subject to recycle timeout if there are no http requests to it. Its not clear how is the monitoring of the other service done, but without external request the IIS will put service to sleep, so perhaps change the monitored service so that it sends a notification to monitoring service.
If you have selfhosted WCF service, then please discard first paragraph, selfhosted WCF service is not affected by IIS and shouldnt go to sleep unless you turn it off.