Saturday, November 16, 2013

Exception: Network Access for Distributed Transaction Manager (MSDTC) Has Been Disabled

Quite some time ago, some of the developers complained about an exception had been thrown from the TransactionScope. And, I attempted to troubleshoot the problem with one of the developers together.

Here is the story. The following is the exception detail:

Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool.

If you google around, the given solution normally is asking you to make sure the Distribute Transaction Coordinator (DTC) is configured properly and firewall is cleared, but I still get the same exception.

During the troubleshooting process, I found that there were different connection strings being used, which is like this:

<connectionStrings>
  <add name="db1"
       connectionString="server=myServer1;database=myDataBase; uid=myUser;password=myPassword;"
       providerName="System.Data.SqlClient" />
  <add name="db2"
       connectionString="Data Source=myServer2;Initial Catalog=myDataBase;User ID=myUser;Password=myPassword;"
       providerName="System.Data.SqlClient" />
</connectionStrings>

The developer went on to change one of the connection string to make them using the same format. The result is no more exception had been thrown.

This is weird and went on to search for the difference between these 2 connection string. Base on the article from MSDN - http://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx, they are synonymous with each other. But, DTC does not treat them the same. I do not know why and how TransactionScope internal work. Perhaps, you tell me why if you come across this page and know the answer.

Conclusion, the above exception message is rather useless and sound like a common error message for anything which is related to DTC. Do not just check your DTC configuration, but also check your connection strings.

UPDATE ADD-ON:

There are some people asking more about how to troubleshoot this error. Besides the connection string issue stated as above, there are actually more thing to check:

1. Firewall

Please ensure that you have unblock the firewall for DTC in all related web server and database server.

Inbound Rule:


Outbound Rule:



2. DTC Windows Service

Make sure the Distributed Transaction Coordinator service is running in all related web server and database server.


3. Hostname Resolve

Make sure all the server hostname are able to be resolved in all related web server and database server. Either update the DNS server and then flush the DNS cache by executing ipconfig.exe /flushdns command or add in hostname in the host file manually which is located at C:\Windows\System32\drivers\etc\hosts.

For instance, you have a web server and two database server. Web server must be able to ping both database servers with server name instead of IP address. The database server must be able to ping the web server and the other database server too by pinging both servers hostname.

4. Configure MSDTC Security

Run the command dcomcnfg, then expand the Component Services all the way down to Distributed Transaction Coordinator. Right click the Local DTC, then click the Properties.


Enable the Network DTC Access and remain the default configuration.



3 comments:

  1. thanks, it saved my time :)

    ReplyDelete

  2. Network Access Control is the significant way to access the features of network and the devices of it to keep it secure from all kinds of attacks. Securium Solutions is one of the best companies that gives Network Access Control services in India.

    ReplyDelete

Send Transactional SMS with API

This post cover how to send transactional SMS using the Alibaba Cloud Short Message Service API. Transactional SMS usually come with One Tim...