tags:

views:

24

answers:

1

Hi All

I have a service that uses callback operations to call back its client. Is there a away to notify the client when Service goes down? An exception is raised when client goes down during callback, but with service goes down the subscription is lost but client is not notified.

Does WCF support some heartbeat operation to check the state of the service?

Thanks

A: 

No, there's no such thing as a "check if this service call will succeed" method.

You need to call the service and be prepared to handle any exceptions that occur during the service call.

There's really no reliable or useful way to check for service availability. All that a heartbeat could check for is that you can call your service method right now - but a fraction of a second later, that connection might be gone (cable has been unplugged or severed, server has crashed - the possibilities of things going wrong are endless......), too. It cannot check if all the necessary background services and databases etc. are available.

So in reality, such a heartbeat check is quite pointless. Just call the service, hope for the best, and be prepared for the worst! Wrap your service calls in good exception handling, and get on with it.

marc_s
Well I was thinking of maintaining a timer on the client which gets reset to 0 with every callback and if the timer reaches a limit say 2 minutes then send a heartbeat to check whether server is still running.
joblot
@joblot: yes, sure, you can do that - but what does this **really** tell you?? WCF services are typically "per-call" - every request gets a new service object which handles its request. Doing this heartbeat just proves that every 2 minutes, you can reach your service and call a method. It says **nothing** about whether the real functions can do their work, and it says **nothing** about whether your service will be available 10 seconds later. WCF services are **not** like an ADO.NET database connection that's open for an extended period of time.
marc_s
please check this link http://stackoverflow.com/questions/3255117/instance-session-and-concurrency-for-duplex-servicei hope this will give clarity on what I am trying to achieve. i just need to log a error to a log file if service is unavailable.I assume with PerSession instance and SessionMode.Required the heartbeat request will be handled by the same insatnce and if there si no reply then something is wrong with the service.well at least service state can be queried after an inetrval instead client waiting for callbacks, where connection cant be reestablished.
joblot