WCF service hosting in IIS 7 (WAS) with net.tcp binding to two Tcp ports

By default, the IIS 7 website has a net.tcp binding with the binding information string "808:". If I add another net.tcp binding with the exception "xxx:":

This collection already contains the address with the net.tcp schema. This collection can have no more than one address per scheme. Parameter Name: item

How can I solve this problem and listen to my service on two ports?

+5
source share
3 answers

Basically, in your service you should be able to define any number of service endpoints on any number of ports.

There are two ways to do this:

№1, - :

<service name="YourService">
  <host>
    <baseAddresses>
      <add baseAddress="net.tcp://YourServer:5151/Services" />
    </baseAddresses>
  </host>
  <endpoint name="endpoint1"
            address="Service1"
            binding="netTcpBinding"
            contract="IYourService" />
  <endpoint name="endpoint2"
            address="Service2"
            binding="netTcpBinding"
            contract="IYourService" />
</service>

, , URL-

net.tcp://YourServer:5151/Services/Service1

net.tcp://YourServer:5151/Services/Service2

mulitple, .

- :

<service name="YourService">
  <endpoint name="endpoint1"
            address="net.tcp://YourServer:5151/Services/Service1"
            binding="netTcpBinding"
            contract="IYourService" />
  <endpoint name="endpoint2"
            address="net.tcp://YourServer:6868/Services/Service2"
            binding="netTcpBinding"
            contract="IYourService" />
</service>

, , TCP, . . , .

+8

WCF - . : p >

http. . : item

, - , . , - , WCF . web.config :

<serviceHostingEnvironment>
<baseAddressPrefixFilters>    
    <add prefix=http://MyHostHeader />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
+2

.

 <baseAddresses>
            <add baseAddress="net.tcp://localhost" />
            <add baseAddress="net.tcp://localhost:12345" />
 </baseAddresses>

IIS7 + WAS

net.tcp://localhost: 12345/game2.svc. 00: 00: 02.0936160. 10061 TCP: , 127.0.0.1:12345.

IIS

0

All Articles