Scenario:
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 0.0.0.0:9000. 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
Reason:
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.
Solution:
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)
Code:
Article:
<system.serviceModel>
<bindings>
<netTcpBinding name="customBinding"
portSharingEnabled="true" />
<services>
<service name="MyService">
<endpoint address="net.tcp://localhost/MyService"
binding="netTcpBinding"
contract="IMyService"
bindingConfiguration="customBinding" />
</service>
</services>
</system.serviceModel>
TCP View
2 comments:
Thanks, it helped
You can also use port no 8081
in address="net.tcp://localhost:8081/MyService
Post a Comment