开发者

Problem with having 2 endpoints : wsHttpBinding and netTCPBinding

开发者 https://www.devze.com 2023-03-22 20:47 出处:网络
I am learning WCF and developed a service first with wsHttpBinding and hosted it on a IIS7 (win7) and consumed the service from a Windows client application. It was working fine (used the WCF Service

I am learning WCF and developed a service first with wsHttpBinding and hosted it on a IIS7 (win7) and consumed the service from a Windows client application. It was working fine (used the WCF Service DLL method)

I tried to have two endpoints and added netTCpBinding. I encounter an error

{The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: failed to start the service because it is disabled.

I have started the required services and even rebooted my machine. In "services" the 2 services show as started itself.. I have enabled the needed tcpnetbinding settings in IIS as informed by many blogs and msdn.

My client app config is this:

 <configuration>    
    <system.serviceModel>
        <bindings />
        <client>
           <endpoint name="httpEndpoint"
               address="http://MachineName:8000/FLOW5WCFService.svc"
               binding="wsHttpBinding"
               contract="FLOW5ServiceDLL.IFLOW5WCFService"/>
           <endpoint name="tcpEndpoint"
               address="net.tcp://MachineName:8082/FLOW5WCFService.svc"
               binding="netTcpBinding"
               contract="FLOW5ServiceDLL.IFLOW5WCFService"/>
        </client>
    </system.serviceModel>
</configuration>

Service web.config:

<configuration>
   <system.serviceModel>
      <bindings>
         <netTcpBinding>
              <binding name="tcpBinding" 
                  portSharingEnabled="true"
                  closeTimeout="00:10:00" openTimeout="00:10:00"
                  receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="true"
                  hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
                  maxReceivedMessageSize="2147483647">
                  <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                      maxArrayLength="2147483647" maxBytesPerRead="4096" 
                      maxNameTableCharCount="320000" />
              </binding>
         </netTcpBinding>
      </bindings>
      <services>
          <service behaviorConfiguration="FLOW5ServiceDLL.FLOW5WCFServiceBehaviour" 
                   name="FLOW5ServiceDLL.FLOW5WCFService">
             <endpoint 
                 address="" 
                 binding="wsHttpBinding" 
                 contract="FLOW5ServiceDLL.IFLOW5WCFService">
                 <identity>
                     <dns value="localhost" />
                 </identity>
             </endpoint>
             <endpoint
                 binding="netTcpBinding"
                 bindingConfiguration="tcpBinding"
                 contract="FLOW5ServiceDLL.IFLOW5WCFService"/>
            <endpoint 
                address="mex" 
                binding="mexHttpBinding" 
                contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                     <add baseAddress="http://localhost:8000/" />
                     <add baseAddress="net.tcp://localhost:8082" />
                </baseAddresses>
            </host>
        </service>
   </services>
   <behaviors>
       <serviceBehaviors>
            <behavior name="FLOW5ServiceDLL.FLOW5WCFServiceBehaviour">
               <serviceMetadata 开发者_StackOverflowhttpGetEnabled="false" />
               <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
       </serviceBehaviors>
   </behaviors>
</system.serviceModel>
<system.web>
    <compilation debug="false" />
</system.web>
</configuration>

I am creating a channel as follows in my client code

ChannelFactory<IFLOW5WCFService> protocolFactory 
      = new ChannelFactory<IFLOW5WCFService>("tcpEndpoint");
l_oFLOW5Service = protocolFactory.CreateChannel();

Could anyone please let me know in case my configs are wrong or is their any other setting I need to do? Please let me know in case any more info is needed

Thanks in advance


I see two things:

1) In your server's web.config, your netTcp endpoint doesn't have an address. If you want to have the netTcp endpoint listen on the default base address for net.Tcp, I would still always put an address="" into my endpoint:

<endpoint
    address=""
    binding="netTcpBinding"
    bindingConfiguration="tcpBinding"
    contract="FLOW5ServiceDLL.IFLOW5WCFService"/>

2) In your client, you don't define any netTcpBinding configuration, while on the server side, you do. I don't see any critical settings in there right now - but just to be safe, I would recommend trying to have an identical netTcpBinding configuration in your client's config, and using that in the client's tcpEndpoint and see if that makes any difference.

If nothing works: why don't you try to disable / turn off the NetTcp port sharing on the server side? I don't really see any need for this in your example here - just try to get along without it - as long as you don't really need it.

0

精彩评论

暂无评论...
验证码 换一张
取 消