.net – How to ping or check status of WCF service using net.tcp endpoint from remote server

netwcf

I really come from the world of Http and never did much with the old .NET Remoting which used TCP, but I understand the TCP concepts and now have implemented several WCF services using the net.tcp binding over the last few years. Most of the time it is up, running, I consume it, end of story. However sometimes the server setup is more advanced and I get communication errors that exist on 1 server and maybe not from another. To prove if it is a firewall/server/etc. issue I need to see if the WCF service can even be seen or reached without issue. This is for a Windows Service hosted WCF service using net.tcp that I am trying to figure out this situation.

The thing is with a WCF service exposed via a HTTP binding, I can just plop the URI in the browser to view the service page letting me know the service is running properly. Easy test.

How do I do the equivalent for a WCF service exposed via a net.tcp binding? Is there any tool or command I can use to test for example net.tcp//mycustomWCFService:8123/MyService ? I have seen a few posts on writing code to programmatically determine if the WCF service is available but I do not want to do it this way. I want to do this check if at all possible without code, analogous to me pulling up the http endpoint in a browser.

Any help is appreciated, thank you!

Best Answer

If your service implements a metadata endpoint (typically named mex and nested beneath the principal endpoint, implemented using the mexTcpBinding in this case), you can "ping" it using the svcutil command line utility that's provided with Visual Studio. E.g.,

svcutil net.tcp://mycustomWCFService:8123/MyService/mex

If it throws an error, your service is (potentially) down. If it succeeds, you're (likely) in business. As the preceding parentheticals suggest, it's an approximation. It means there's a listener at the address and that it's able to service a metadata request.