I have a service and it is hosted in a Windows application. Within the application, the service is started as below
public void Initialise()
{
BasicHttpBinding binding = new BasicHttpBinding();
ServiceHost host = new ServiceHost(typeof(SampleType));
host.AddServiceEndpoint(typeof(ISampleService), binding, "http://localhost:6732/Sample/Service/");
host.Open();
}
Now, if I run multiple instances of the application, I am getting the error
HTTP could not register URL http://localhost:6732/Sample/Service/. Another application has already registered this URL with HTTP.SYS.
Is there any way multiple instances can listen to the开发者_如何学Python same URL?
You need to run it on a different port, try randomising the port number and checking if the port is being used first before launching the service.
You can only run one instance on one port, so the solution is to change the port for each instance how you do it is up to you.
6732 is the port, so maybe increment on each instance or randomise it.
http://localhost:6732/Sample/Service/
Also check these two S0 posts that might help:
WCF: Net.TCP multiple bindings, same port, different IP Addresses
Can 2 WCF service processes listen the same port?
You will not be able to create multiple instances of a service that all receive data sent to a specific address/port, Windows has to direct incoming network traffic to a specific socket listening on that port.
I suspect that what you are trying to do is best achieved through use of a duplex binding such as netTcpBinding. In this case your multiple clients would all connect to the server sending the message and then wait for a callback from that server.
精彩评论