We have a "worker" service running from console application in c#, for development we were always running a single instance of this service, which fetches chunks of data and performs some calculations, these chunks of data are provided by another service (which keeps track of how much data is left etc.)
Now in QA we want to run multiple instances of the "worker" service simultaneously (on the same machine).However we are get an exception as soon as the second instance is launched:
The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: the URI is already registered with the service.
We are using netTcpBinding and the endpoint address is hardcoded into the app.config and remains the same and because of that I assume we are getting this error.
<services>
<service behaviorConfiguration="CoreBehavior" name="WorkerService">
<endpoint address="net.tcp://localhost:8001/WorkerAssignment" binding="netTcpBinding" contract="IWorkerService" bindingConfiguration="CoreTcpBinding"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="CoreTcpBinding" portSharingEnabled="true">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
Application code :
var host = new ServiceHost(typeof(WorkerService));
host.Open();
How do we provide a different URI for each instance so that atleast the port will remain the same ?
OR If there is a different way to run multiple instances of the same service?