tags:

views:

29

answers:

1

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 same URL?

A: 

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:

http://stackoverflow.com/questions/703051/wcf-net-tcp-multiple-bindings-same-port-different-ip-addresses

http://stackoverflow.com/questions/2085790/can-2-wcf-service-processes-listen-the-same-port

kyndigs
In this case , the overall endpoint addresses is still needs to be unique. In my case I want to use the same address also on having a service request, I like to get that request in all instances of service host
zsquare