views:

1565

answers:

4

I'm getting the following error when I try multiple end points..

System.ServiceModel.AddressAlreadyInUseException: The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: the service failed to listen.
   at System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.Register()
   at System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.Open(Boolean isReconnecting)
   at System.ServiceModel.Channels.SharedConnectionListener.StartListen(Boolean isReconnecting)
   at System.ServiceModel.Channels.SharedConnectionListener..ctor(BaseUriWithWildcard baseAddress, Int32 queueId, Guid token, OnDuplicatedViaDelegate onDuplicatedViaCallback)
   at System.ServiceModel.Channels.SharedTcpTransportManager.OnOpenInternal(Int32 queueId, Guid token)
   at System.ServiceModel.Channels.SharedTcpTransportManager.OnOpen()
   at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
   at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
   at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.TcpChannelListener`2.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ReliableChannelListenerBase`1.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open()
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

Here's my App.Config contents

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="tcpBinding" transferMode="Buffered" portSharingEnabled="true">
          <reliableSession enabled="true" />
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WcfServiceLibrary1.Service1Behavior"
        name="WcfServiceLibrary1.Service1">
        <endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="Service" binding="netTcpBinding" bindingConfiguration="tcpBinding"
          name="testTcp" contract="WcfServiceLibrary1.IService1" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
            <add baseAddress="net.tcp://localhost:8731/Design_Time_Addresses/WcfServiceLibrary1/Service" />

          </baseAddresses>

        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfServiceLibrary1.Service1Behavior">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

Would be great if someone could guide me where I'm wrong.

Net TCP port sharing service is enabled both in App.Config and Windows Service.That's as far as I could possibly check.

Thanks

+1  A: 

It could be that you're using the same port for the HTTP and TCP bindings. Try changing the port on the TCP binding to 8732 or anything other than 8731.

Andy White
Not, that's not the problem - shouldn't be, at least. But just for fun try it anyway! :-)
marc_s
A: 

It may be a problem with the tcp binding / configuration rather than a problem with multiple bindings.

To test it remove reference to the http binding and see if the tcp binding will work alone.

Shiraz Bhaiji
+2  A: 

You can't share the same exact port between two different bindings, which based on the configuration you have posted above, you are currently doing. You need to have your wsHttp binding on a different port than the net.tcp binding. The purpose of net.tcp port sharing is to allow multiple processes utilize the same port for several net.tcp bindings...not to share a single port across multiple different bindings and protocols.

To successfully utilize WCF net.tcp port sharing, you need to start the 'Net.Tcp Port Sharing Service' (note that it explicitly states Net.Tcp in the name). You will probably also want to set it to Automatic startup, so you don't have to keep starting it if you reboot. Once the port sharing windows service is started, you can share a single port for any net.tcp binding, in the same process, across multiple processes, on the same physical machine. Each net.tcp binding that needs to share a port will need to have the portSharingEnabled property set to true. If you do the above, then you should be able to reuse the same port for any net.tcp endpoint that has port sharing enabled, in any process.

This will not allow you to share that same port with any of the wsHttp bindings, the basicHttp binding, any MSMQ binding, nor any third-party binding. This is a feature that is specific to the netTcpBinding that comes with WCF.

For reference: http://msdn.microsoft.com/en-us/library/ms734772.aspx

jrista
Hi...That makes sense...I thought we could share the same port through multiple binding using tcp port sharing.I changed the port and it worked. Thanks!!
Josh
But then...Isn't HTTP also a kind of TCP? Are there possibilities to make it work on the same port?
Josh
HTTP is an application protocol that operates over the TCP/IP transport. WCF's Tcp.Net is also an application protocol, albeit a proprietary one, that operates over the TCP/IP transport. Both utilize the tcp network transport layer, however they otherwise have no relationship to each other.
jrista
I got it.... :)
Josh
A: 

I´d suggest you enable tracing in order to get a better understanding of the problem. WCF could be a b*tch when it comes to showing error messages.

sebastian