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

Solution 1:

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.

Solution 2:

Another way I found to at least see if it is listening is to issue the following 'netstat' command (from a command prompt) on the installed server:

netstat -ona | find "8123"

(Yes that is a pipe delimiter in the command above). If anything is returned it is actively listening and hosted on the searched port.

Solution 3:

A simple way of doing that would be (assuming the service is hosted in IIS) to add a HTTP binding (using a different port!!) to the same IIS site and to add <serviceDebug httpHelpPageEnabled="true" /> to the service behaviors. That way you can easily check that the service is up by navigating to its HTTP URL in a browser. Admittedly, that way you can only find out whether the service is up or not, you wouldn't be able to detect any networking issues on the particular TCP port, for instance.

If you need to address the latter issue as well, or if adding a HTTP binding is not possible you could just add a simple "PING" operation to the service contract and use a net.tcp client to invoke that one.

Solution 4:

You can also use the telnet client program to discover listening ports, i.e., telnet {url or IP} {port}. To check if a web site is up.. 'telnet www.godaddy.com 80' should initially produce a blank window followed by a Request Time-out response (400) if no commands follow.