I have a service I wrote and deployed in the service.msc list of services. I then wrote a test client to test some of the features. The basic 'first' attempt worked perfect. The issue is when I went back and added new operations I keep getting the following Error:
System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:8080. This could happen if there is another application already listening on this endpoint or if you have multiple service endpoints in your service host with the same IP endpoint but with incompatible binding configurations. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at System.ServiceModel.Channels.SocketConnectionListener.Listen() --- End of inner exception stack trace --- at System.ServiceModel.Channels.SocketConnectionListener.Listen() at System.ServiceModel.Channels.ConnectionAcceptor.StartAccepting() at System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen()
The process I have followed is listed below:
- I stopped the service to free up the .exe file.
- I used 'installutil /u ...' to uninstall my service.
- I added the features needed to the service library.
- I rebuilt the library, then the Windows Service.
- I used 'installutil ...' to install service.
- I used service.msc to start the service (which is Autostart).
- I try to update the service reference to the TestClient and Boom - Error.
- I did steps 1-7 again, but this time changing the /mex and default service addresses to use different ports (per: http://msdn.microsoft.com/en-us/library/aa702636.aspx
- Did step 7 again and Boom - Error Again
I tweaked and piddled with the service several times over again, rewrote the client, etc. Nothing seems to work. Funny thing is it worked fine the first try, now there are issues. I have already ensured that my service is the only one on it's port using 'netstat -aon' and 'tasgmgr.exe'. These all look fine. The host runs, everything up to the test client is fine. Now the end points use different ports so the TCP Mex issue should be solved according to online documentation. Am I missing something here? I was able to generate a proxy using 'svcutil' and I ensured the App.Config data does not conflict.
Below is the App.Config data (as I am using configuration files):
HOST App.Config (service):
<service name="SomeServiceLib.SomeService">
<endpoint address="net.tcp://localhost:8080/SomeService" binding="netTcpBinding" contract="SomeServiceLib.ISomeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8081/SomeService/mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- NOTE: If net.tcp, must set each to false to avoid exception -->
<serviceMetadata httpGetEnabled="False" httpsGetEnabled="False"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
CLIENT App.Config:
<client>
<endpoint address="net.tcp://localhost:8080/SomeService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_SomeService"
contract="SomeService"
name="Svc_DefaultEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.tcp://localhost:8081/SomeService/mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
name="Svc_MexEndpoint">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_SomeService" />
</netTcpBinding>
</bindings>
...