Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSDTC: Communication with the underlying transaction manager has failed

Tags:

c#

.net

wcf

msdtc

I have a WinForms / WCF / SQLServer app where I am trying to use MSDTC transactions like this:

using System.Transactions;

// ...

var transOptions =
    new TransactionOptions
    {
        IsolationLevel = IsolationLevel.ReadCommitted,
        Timeout = TimeSpan.FromSeconds(120)
    };

using (var scope = new TransactionScope(TransactionScopeOption.Required,
         transOptions))
{
    // ...

    if (everything_is_ok)
        scope.Complete();
}

On my dev. box, where the server and client processes are on the same machine, it works fine. But when I deploy to the QA env, where server and client are on separate machines, whenever scope.Complete() is called, the client hangs for the timeout period (2 minutes) and then I get:

The flowed transaction could not be unmarshaled. The following exception occurred: Communication with the underlying transaction manager has failed.

What can cause this?

like image 766
JoelFan Avatar asked Sep 01 '11 21:09

JoelFan


People also ask

What port does Msdtc use?

MSDTC on the database server computer uses RPC dynamic port allocation to randomly select a port number ranging from 1024 to 65535 for communication with the central computer.

What is Msdtc service?

The Microsoft Distributed Transaction Coordinator (MSDTC) service is a component of modern versions of Microsoft Windows that is responsible for coordinating transactions that span multiple resource managers, such as databases, message queues, and file systems.


2 Answers

I spent few hours today trying to resolve this problem under Windows 7. Finally it worked, here's what I did:

  1. Enable MSDTC and allow inbound/outbound transactions (via Control Panel)
  2. The guide for opening ports via registry - just follow the guide
  3. Allow ports defined in (2) to be open in your firewall (in case you use one)
  4. Allow MSDTC through the windows firewall - add new rule for inbound connections to msdtc.exe (should be in %systemroot%\system32)

This is maybe not the best solution but in fact the only one that worked in my case.

EDIT: After another issue with MSDTC under Windows 7 SP1 I found out that there are two things you need to do in order to make it work.

  1. Add to hosts file a mapping between the IP and NetBIOS name of the server.
  2. Add (or edit) two keys at HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\RPC: "RestrictRemoteClients"=dword:00000000 "EnableAuthEpResolution"=dword:00000000
like image 165
Konrad Avatar answered Oct 18 '22 20:10

Konrad


I had similar issue and it got resolved when the administrator set MaxUserPort registry key value as 65534. [The issue happened in a clustered server setup only]

enter image description here

REFERENCES

  1. MaxUserPort - what it is, what it does, when it's important
  2. Intermittent msdtc problems

Other References

  1. DTCPing: Troubleshooting MSDTC Connectivity Issues
  2. "Communication with the underlying transaction manager has failed" error message
  3. Windows firewall blocking MSDTC
  4. DTC Resource Fails on Cluster
  5. http://support.microsoft.com/kb/909444
  6. Troubleshooting MSDTC
  7. Kernel Transaction Manager
  8. MSDTC Client Error
like image 23
LCJ Avatar answered Oct 18 '22 21:10

LCJ