WCF-NetTcp receive Adapter : Port Sharing issues

When we create a WCF- NetTcp receive location in BizTalk server, the receive location acts itself as a wcf service and is hosted in BTSNTSvc (BizTalk process).
Now the service can be invoked by different type of client to submit message to the BizTalk layer.

 

Now, net.tcp://localhost/SampleTestService/receiveInvoice.svc can be used as WCF service.
Suppose I want to have another receive location to receive PO, so I create another receive location


Now, net.tcp://localhost/SampleTestService/receivePO.svc is another WCF service.

But, when I enable the receive location I get the error
The Messaging Engine failed to add a receive location "TstRcvLocPO" with URL "net.tcp://localhost/SampleTestService/receivePO.svc" to the adapter "WCF-NetTcp".
Reason: "System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:808

Since, there is more than one service using the same port 808 we will have to enable port sharing, if you want to use 808 for both the service.
Enable port Sharing service in the services.msc

After enabling the port Sharing service you will be able to resolve the above error.
But when you are using the WCF-custom adapter you will additionally have to enable port sharing property in the binding tab of the receive location.

 
Suppose, you have one receive location with WCF-NetTcp adapter and another one with WCF-custom adapter with NetTcp binding both are using the same port 808,
now even though I have enabled port sharing option both in receive location and the service. I will still the same error

The Messaging Engine failed to add a receive location "TstRcvLocPO" with URL "net.tcp://localhost/SampleTestService/receivePO.svc" to the adapter "WCF-NetTcp".
Reason: "System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:808

This is because the WCF-NetTcp adapter and the WCF-custom adapter with NetTcp binding recognize each other as a different binding and will not be able to share the same port between each other.
In order to overcome such a problem you will have to create different port for either the WCF-custom or the WCF-NetTcp adapter.

I changed the adapter to something like this

Now the WCF-custom receive location is using the port 810 and I was able to use the receive location.

Note:- please make sure you share the new URI with the clients that are using the receive location, that is along with the port number.
net.tcp://localhost:810/SampleTestService/ReceivePOcustom.scv

Hope this is useful for the BizTalk developer like me. Happy BizTalking!!

 Written by
Shashidharan Krishnan

Reviewed by
Shailesh Agre

Microsoft GTSC