Search code examples
c#wcf

Fastest way to check if WCF endpoint is listening


Often, if a WCF endpoint is unavailable (in my case, usually because the service host is not running), I'll get an EndpointNotFoundException after a timeout. I'd like to have a fast way to query the service to see if it's available without having to rely on the normal timeout. In other words, I want to keep a normal timeout for normal circumstances, but for a quick "ping" of the endpoint, I want it to fail fast if it's not available right away.

How could this be accomplished?


Solution

  • You will have to wait for a TimeOut exception. You can set (override) the TimeOut when creating the Proxy object. They're cheap so make a temp proxy for the Ping.

    On the server side, you could make sure there is a lightweight function to call (like GetVersion).