WCF net tcp port sharing

I have 2 WCF services, each of which is hosted in its own console application.

They are located at:

net.tcp://computername:7777/Service1
net.tcp://computername:7777/Service2

everyone has their own contract. I want them to use the same port, so I read a lot on this issue and did the following:

  • Enable tcp network sharing service.
  • Register URL with commands:

netsh http add urlacl user=domain\username url=net.tcp://+:7777/Service1

netsh http add urlacl user=domain\username url=net.tcp://+:7777/Service2

  • enabled PortSharingEnabled=truein bindings for each WCF service
  • placement of each in its console application.

if I run both console applications, the second always gives this exception when calling the host method Open():

    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 as in the same console application, everything works fine.

:, , .

+4
1

Jon_Lindeheim, , . :

WCF, URI
1:

    <add baseAddress = "net.tcp://computername:7777/" />
    ...
    <endpoint address = "/service1" ... />

2:

    <add baseAddress = "net.tcp://computername:7777/" />
    ...
    <endpoint address = "/service2" ... />  

, URI.

: 1:

    <add baseAddress = "net.tcp://computername:7777/service1/" />
    ...
    <endpoint address = "/service1" ... />

2:

    <add baseAddress = "net.tcp://computername:7777/service2/" />
    ...
    <endpoint address = "/service2" ... />  

( , , , , ).

+2

Source: https://habr.com/ru/post/1540510/


All Articles