Issue with socket connecting protocol net.tcp via WCF

532 Views Asked by At

I had came across this scenario's for all the below use cases. Except Case 3 which is normal & general and rest of the cases needs to be resolved

These below Services were running without any errors:

  1. Net.Msmq Listener Adapter
  2. Net.Pipe Listener Adapter
  3. Net.Tcp Listener Adapter
  4. Net.Tcp Port Sharing Service
  5. Windows Process Activation Service

also Enabled Protocols: net.tcp,http

From the command line or via application when calling WCF written services:

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools>svcutil net.tcp://localhost/TNA/TAServices/AuthenticationManager/mex

Case 1:

Could not connect to
net.tcp://localhost/TNA/TAServices/AuthenticationManager/mex. The
connection attempt lasted for a time span of 00:00:04.0935290. TCP
error code 10061: No connection could be made because the target
machine actively refused it 127.0.0.1:808.
No connection could be made because the target machine actively refused it 127.0.0.1:808

Case 2:

There was no endpoint listening at
net.tcp://localhost/TNA/TAServices/AuthenticationManager/mex that
could accept the message. This is often caused by an incorrect address
or SOAP action. See InnerException, if present, for more details.

Case 3:

The socket connection was aborted. This could be caused by an error
processing your message or a receive timeout being exceeded by the
remote host, or an underlying network resource issue. Local socket
timeout was '00:04:59.9843875'.
An existing connection was forcibly closed by the remote host

Event Log for Case 2:

An error occurred in the Activation Service 'NetTcpActivator' of the protocol 'net.tcp' while trying to listen for the site '1', thus the protocol is disabled for the site temporarily. See the exception message for more details.
 URL: WeakWildcard:net.tcp://username.domainname.com/
 Status: FailedToListen
 Exception: System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:808. This could happen if there is another application already listening on this endpoint or if you have multiple service endpoints in your service host with the same IP endpoint but with incompatible binding configurations. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()
   at System.ServiceModel.Activation.TransportListener.Go(IConnectionListener connectionListener)
   at System.ServiceModel.Activation.TransportListener..ctor(IPEndPoint endPoint)
   at System.ServiceModel.Activation.TransportListener.Listen(IPEndPoint endPoint)
   at System.ServiceModel.Activation.RoutingTable.TcpStart(MessageQueue messageQueue, BaseUriWithWildcard path)
   at System.ServiceModel.Activation.MessageQueue.Register(BaseUriWithWildcard path)
   at System.ServiceModel.Activation.ListenerAdapter.RegisterBindings(IActivatedMessageQueue queue, Int32 siteId, String[] bindings, String path)
 Process Name: SMSvcHost
 Process ID: 4608

How should we need to achieve to go to case 3 by default, whenever, at times such as Booting and rebooting the system?

1

There are 1 best solutions below

0
Abraham Qian On

Case 1 and Case 2 require a Mex service endpoint in the WCF service configuration. Please add a Mex endpoint to exchange the service metadata.

<system.serviceModel>
        <services>
            <service name="WcfService1.Service1">
                <endpoint address="service1" binding="basicHttpBinding" contract="WcfService1.IService1" ></endpoint>
                <endpoint address="service2" binding="netTcpBinding"  contract="WcfService1.IService1"></endpoint>
                <!--for exchanging service metadata.-->
                <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"></endpoint>
            </service>
        </services>

Feel free to let me know if there is anything I can help with.