Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

.net

wcf

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!

like image 259
atconway Avatar asked Jun 10 '11 17:06

atconway


People also ask

Does WCF use TCP?

The WCF TCP transport is optimized for the scenario where both ends of the communication are using WCF. This binding is the fastest WCF binding for scenarios that involve communicating between different machines.


2 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.

like image 107
Jason Shantz Avatar answered Oct 07 '22 01:10

Jason Shantz


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.

like image 24
atconway Avatar answered Oct 07 '22 01:10

atconway