Friday, April 10, 2009

WCF : Already a listener on the IP endpoint

While testing my WCF service using netTCP binding, I got the following error.

Error:Unhandled Exception: System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint Make sure that you are not trying to use this endpoint multiple times in your application and that there are no other applications listening on this endpoint. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted

NetTcp Port Sharing is a Windows Communication Foundation (WCF) feature that is similar to IIS and allows multiple network applications to share a single port. The NetTcp Port Sharing Service accepts connections using the net.tcp protocol and forwards messages based on their destination address.But NetTcp Port Sharing Service is not enabled by default.

1. You can also use TCPView to check what process that is holding the port open.
2. Check using following command
netstat -a | find "portno"
3. Try restarting the service or server
4. Try configuring the service on different port number
5. You can try enabling port sharing ( require NetTcp Port Sharing Service running)


<netTcpBinding name="customBinding"
portSharingEnabled="true" />
<service name="MyService">
<endpoint address="net.tcp://localhost/MyService"
bindingConfiguration="customBinding" />
TCP View


Anonymous,  May 18, 2010 at 4:50 PM  

Thanks, it helped

Syed Tayyab Ali June 11, 2011 at 6:21 PM  

You can also use port no 8081
in address="net.tcp://localhost:8081/MyService