How Transactions work on WCF

One of this days I had this scenario where I needed to discuss with some colleagues how to configure Transactions support for WCF services, doing this I realize that there is indeed a great deal of lack of knowledge around this topic.

I made some research to see what's out there and despite some very good articles, it seems to be missing something that in clear way clarifies the most important aspects of this type of configuration, so I decided to write a small article about that.

So, going straight to point, first of all we need to understand that all WCF transactions internally uses a built-in windows component called Distributed Transaction Coordinator (MSDTC).

On the other side, MSDTC uses DCOM protocol as the underlying technology, and for DCOM communication to work successfully between 2 machines, some ports need to be open BI-DIRECTIONALLY (this is very important).

Another important point, is that when using Distributed Transactions we will be relying on the RPC, this is an inter-process communication (IPC) method that is used by clients and servers to communicate with each other. Simply put, RPC is used by programs, typically on a client computer, to execute a program on a server computer.

Integral to this process is the endpoint—the name, port, or group of ports on a computer that is monitored by a server for incoming client requests. More specifically, it is a network-specific address of a server process that is used for RPCs.

The Endpoint Mapper, which is part of the RPC subsystem, is responsible for responding to the clients’ requests to resolve dynamic endpoints. In some situations, Endpoint Mapper is also responsible for dynamically assigning endpoints to servers.

For Endpoint Mapper (EPM) communication, we need port 135 to be open.

Other important piece of information regarding this scenario is the fact that a RPCSS service is the Service Control Manager for COM and DCOM servers. It performs object activations
requests, object exporter resolutions and distributed garbage collection for COM and DCOM servers.

So, we need to be aware that RPCSS can assign any dynamic TCP port for MSDTC communication, and the default dynamic port range for a Windows 2008 server is 49152 – 65535.

Finally, and this is also a very important, we need to understand that as part of the DCOM Communication we should not be using any NAT implementation in this communications.

To summarize:

Ports 135, 49152-65535 should be open bi-directionally between the any WCF Server and the corresponding SQL Server.

Now, hope that this will help, for more reading and clarification you can read these two articles that lists the configuration and code changes necessary for transactions in WCF
WCF Transactions - Brief Introduction
Transactions in WCF Services

More details on this topic:
Troubleshooting MSDTC issues with the DTCPing tool
Troubleshooting Problems with MSDTC
The default dynamic port range for TCP/IP has changed in Windows Vista and in Windows Server 2008
DCOM Does Not Work over Network Address Translation-Based Firewall

Comments (0)

Skip to main content