0

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?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
zsquare
  • 1
  • 1
  • 1
  • The big question is: **WHY??** Even with a single ServiceHost, you can easily service multiple requests at the same time. Why do you want to run multiple instances?? – marc_s Oct 14 '10 at 11:58
  • @marc_s - he could be wishing to test multiple instances of a client/server on the same machine. – kyndigs Oct 14 '10 at 12:01
  • I have another application and from this application I should be able to send messages to all the instance of service hosted application. I know there are other options for communication between the process but looking for a solution using WCF – zsquare Oct 15 '10 at 03:55

2 Answers2

0

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.

Nathan Phillips
  • 11,899
  • 1
  • 31
  • 24
0

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?

Community
  • 1
  • 1
kyndigs
  • 3,074
  • 1
  • 18
  • 22
  • 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 Oct 15 '10 at 04:00