Saturday, June 27, 2009

Choosing a right port number for WCF Endpoint

Scenario:
While installing an endpoint for WCF Host service, we wanted to look for a port which is not being used by any other program for communication, to avoid any issues. Also we had many other WCF Host services in pipeline, so we wanted a standard way of choosing an unused port on our servers.

Solution:
PortQry was the solution. There is a command line version and a UI based version available for download from Microsoft.

PortQryV2.exe is a command-line utility that you can use to help troubleshoot TCP/IP connectivity issues. Portqry.exe runs on Windows 2000-based computers.The utility reports the port status of TCP and UDP ports on a computer you choose.

Download Command Line Utility

Download UI Based Utility

Examples :

The following command tries to resolve "reskit.com" to an IP address and then queries TCP port 25 on the corresponding host:

portqry -n reskit.com -p tcp -e 25
The following command tries to resolve "169.254.0.11" to a host name and then queries TCP ports 143,110, and 25 (in that order) on the host that you selected. This command also creates a log file (Portqry.log) that contains a log of the command that you ran and its output.
portqry -n 169.254.0.11 -p tcp -o 143,110,25 -l portqry.log
The following command tries to resolve my_server to an IP address and then queries the specified range of UDP ports (135-139) in sequential order on the corresponding host. This command also creates a log file (my_server.txt) that contains a log of the command that you ran and its output.
portqry -n my_server -p udp -r 135:139 -l my_server.txt
Article:
KB Article

0 comments: