NServiceBus and Distributed Transaction Coordinator(DTC)

In my recent project I was using NServiceBus for communicating through messaging across different services. Though I had implemented a number of handlers before and deployed them on a remote server but didn't experienced the DTC issue until I tried to access a database server on a machine that is different from the one where the transactional handler service was deployed.

NServiceBus uses Distributed Transaction Coordinator for managing the messages in queue and to make it working its important to make sure that MSDTC running on both machines are configured correctly. Otherwise it would throw the following exception as it was in my case: 
System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed. ---> System.Runtime.InteropServices.COMException: The MSDTC transaction manager was unable to push the transaction to the destination transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers.
While I was investigating this issue, I tried DTCPing tool to figure out the problem with MSDTC process running in both machines. I found no failure there, but still no luck with the NServiceBus handler. Finally I got rescued by following Distributed Transaction Coordinator section of this link: http://nservicebus.com/Transactions.aspx

I added the port range for MSDTC and set the security settings as described in that article.
Well, still it wasn't working for me until I checked firewall settings on both machines. That's the easiest part: go to windows firewall from control panel, open "allow a program or feature through windows firewall" dialog and then check Distributed Transaction Coordinator for public network.




Finally I had to add a inbound rule to open the port range specified for MSDTC on the database server and another similar outbound rule on the machine running the handler.

And now the handler is running well after correcting the MSDTC configuration and firewall settings on both machines.

Comments

Popular posts from this blog

Adding security headers to prevent XSS and MiTM attacks in .Net Core

Creating transformations for custom config files

Microsoft.IdentityModel.Protocols.OpenIdConnectProtocolInvalidNonceException