I have 2 WCF services each hosted in its own console app.
they are hosted at:
net.tcp://computername:7777/Service1
net.tcp://computername:7777/Service2
each has its own contract. i want them to use the same port, so i read a lot on the subject, and did the following:
netsh http add urlacl user=domain\username url=net.tcp://+:7777/Service1
netsh http add urlacl user=domain\username url=net.tcp://+:7777/Service2
PortSharingEnabled=true
on the bindings in for each WCF serviceif i start both console apps, the second one always gives this exception on the call to the host's Open()
method:
AddressAlreadyInUseException. The transport manager failed to listen on the supplied
URI using the NetTcpPortSharing service: the URI is already registered with the
service.
when i host them both in the same console app, it all works just fine.
my question is: how to get it working when each service is hosted in it's own console app.
Windows Communication Foundation (WCF) provides a new TCP-based network protocol (net. tcp://) for high-performance communication. WCF also introduces a new system component, the Net. TCP Port Sharing Service that enables net. tcp ports to be shared across multiple user processes.
As a security precaution, an administrator must manually enable the Net. TCP Port Sharing Service prior to first use. The Net. TCP Port Sharing Service exposes configuration options that allow you to manipulate several characteristics of the network sockets owned by the port sharing service.
In the Name column of the list of services, right-click the Net. Tcp Port Sharing Service, and select Properties from the menu. To enable the manual start-up of the service, in the Properties window select the General tab, and in the Startup type box select Manual, and then click Apply.
Port 808 is the Microsoft Net. TCP Port Sharing Service. "Windows Communication Foundation (WCF) provides a new TCP-based network protocol (net. tcp://) for high-performance communication.
As Jon_Lindeheim and you stated, this should work fine. so i recreated everything from scratch as follows:
I have two WCF services that had the same base address and a different relative URI
i.e.
for service 1:
<add baseAddress = "net.tcp://computername:7777/" />
...
<endpoint address = "/service1" ... />
and for service 2:
<add baseAddress = "net.tcp://computername:7777/" />
...
<endpoint address = "/service2" ... />
I was not aware that base addresses must be different not just the eventual absolute URI.
so the following works fine: for service 1:
<add baseAddress = "net.tcp://computername:7777/service1/" />
...
<endpoint address = "/service1" ... />
for service 2:
<add baseAddress = "net.tcp://computername:7777/service2/" />
...
<endpoint address = "/service2" ... />
(why the first erroneous way still works when all is in one process, i think it's related to the way port sharing routes the traffic on a process based way).
Thanks again
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With