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.
As demonstrated in the Multiple Endpoints sample, a service can host multiple endpoints, each with different addresses and possibly also different bindings. This sample shows that it is possible to host multiple endpoints at the same address.
Sometimes in our mind the question arise; can we implement multiple service contract in WCF service? And the answer is, Yes we can.
The first endpoint is defined at the base address using a basicHttpBinding binding, which does not have security enabled. The second endpoint is defined at {baseaddress}/secure using a wsHttpBinding binding, which is secure by default, using WS-Security with Windows authentication.
For two different bindings, we will create two different EndPoints. At client side same service can be consumed by passing EndPoint name.
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
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