简体   繁体   English

使用WCF可靠消息传递检测连接问题

[英]Detecting connection issues with WCF Reliable messaging

We are using WCF/HTTP based application to send messages from a client to a server and need a quick way of detecting that the server has gone down handling messages. 我们正在使用基于WCF / HTTP的应用程序将消息从客户端发送到服务器,并且需要一种快速的方法来检测服务器已停止处理消息。 Ideally we need to detect that the server has gone down before sending the message. 理想情况下,我们需要发送消息之前检测服务器已关闭。 I am investigating using Reliable messaging as this looks to send a " Are you still there message?" 我正在研究使用“可靠消息传递”,因为它看起来像是发送“ 您还在那里吗?”。 just before each request. 在每个请求之前。 However, what I can't find is any way of detecting if this initial check fails in my code - is this possible? 但是,我找不到以任何方式检测此初始检查在我的代码中是否失败-这可能吗?

I found a couple of articles which suggested performing some form of 'PING' to detect if the server is still there but if possible I would rather use Reliable Messaging as this seems a cleaner solution. 我发现了几篇文章,建议执行某种形式的“ PING”来检测服务器是否仍然存在,但如果可能的话,我宁愿使用“可靠消息传递”,因为这似乎是一种更清洁的解决方案。

Any advice would be much appreciated. 任何建议将不胜感激。

"Are you still there message?" “你还在留言吗?” will not help you. 不会帮助你。

Why ?Think of a situation where you have written code like 为什么 ?考虑一下您编写了如下代码的情况

if(service is up)
{
 //do operation
}

When your control hit the line of operation,what if at that particular point of time service goes down.So there is no point in checking if the service is up or down,instead do something if the service goes down. 当您的控件处于运行状态时,该服务在该特定时间点将如何关闭。因此,没有必要检查该服务是打开还是关闭,而无需检查服务是否关闭。

   try
{
   //do operation
}
catch(Exception ex)
{
//what to do when service is down.
}

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

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