We need to monitor the health of the WCF services, availability of the WCF services. Are they up or down?
But we don’t want to call operations of the service because it sometime could change the service internal status and these changes are out of our control.
Some services have special Heartbeat() operation to make the health monitoring easily, but the most have not.
We don’t have to check the work status of the web-method. That means we don’t care if some underlying services, like SQL databases, don’t work and the services available but response with errors. We just want to know are web-services up or down, could they response at all or not. It should be something really easy.
I thought this is quite routine task to the service consumers and there should be several routine decisions.
As I know the OpsMngr2007 use something simple to measure the web-service health.
“A one way Ping() method on the server works well. If there is an exception, then the channel is broken. You can have a timer run Ping against the server at some interval.
If this is a duplex callback system you need to be careful. The server might also need to check if the client is still alive. You cant have both the servicecontract and callbackcontract have the same named methods, so you will have to rename one of them.”
I’ve tried to
>ping http://text.company.com/adfadfad/asdfadf/adfadfadf.asmx
and
>ping http://text.company.com/adfadfad/asdfadf/adfadfadf.asmx?wsdl
The ping works only for the host name, like
>ping text.company.com
not for web-service URL
It is not what I want.
It checks the health of the host, not the web-service.
It does not cover cases with several services on the one host.
It does not cover cases when the host is OK but the service is not response.
“try to subscribe to the events of the communication object (in the client side), so if a service stopped or disconnected you may handle the fault event.. (remember that it can only fault once).
proxy.InnerChannel.Faulted += new EventHandler(InnerChannel_Faulted);
or
proxy.InnerDuplexChannel.Faulted += new EventHandler(InnerDuplexChannel_Faulted);
see my example of handling a service in a chat application
http://www.codeproject.com/KB/IP/WCFWPFChatRoot.aspx
if this is a duplex communication, to handle the service on the service side, try to check every time on each callback object you have, to see if someone has been aborted or not before you using it (may be a client disconnect for a network failure.. etc.)”
Islam, thanks for response!
It is not our case. We want to check the availability not “post mortem” but proactively. For instance, click a button and get health of all services. And we cannot call the service operations, it’s one of requirements.
“…
Additional ideas (for IIS/HTTP WCF Services) are
1) a custom availability operation in your service which checks all resources and gives back a result your web application monitor can parse.
2) enable WCF performance counter and create a monitor on top of that.
3) buy Avicode MP (should provide native WCF Service support)”
Yeah, 1) is the Heartbeat() operation. It doesn’t work in my case where the services are out of mu control.
For 2) First, we want actively to request the health status not to listen how the service responses to the requests of the other clients.
Second, the WCF performance counters… OK I use them with OpsMng2007 I don’t like them very-very much. (It’s another story).
3) The third-part utils should use the same APIs we use, not something secret. I also use OpsMngr2007. But I want to use simple and absolutely open (to me) source code.
So far so good.
Is it possible to use Mex endpoint or something like HttpRequest to <URL>?wsdl to make sure the service is up?
I’ve got one method from the book “Programming WCF Services” by Juval Lowy (page 71).
Code Snippet:
MetadataExchangeClient mexClient =
bool isServiceUp = true;try
{
string address = “http://localhost/MyService.svc?wsdl”;new MetadataExchangeClient(new Uri(address),MetadataExchangeClientMode.HttpGet);
MetadataSet metadata = mexClient.GetMetadata();
// if service down I get the exception
}
catch (Exception ex)
{
isServiceUp = false;
}