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

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!

Answers


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.


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.


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.


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.


Need Your Help

Loading a large hprof into jhat

java memory-leaks jvm heap jhat

I have a 6.5GB Hprof file that was dumped by a 64-bit JVM using the -XX:-HeapDumpOnOutOfMemoryError option. I have it sitting on a 16GB 64-bit machine, and am trying to get it into jhat, but it keeps

PHP remove/fix module not found or already loaded warnings?

php php-ini

When i run a php script from the command line like below