开发者

Timeout problem in distributed transaction over WCF net.tcp binding

I have a strange timeout problem when running a distributed transaction over a WCF net.tcp binding. The transaction always times out after exactly 10 minutes. I think I have set all the timeouts I know to a higher value than that (15 minutes) but I'm probably overlooking something. I'm calling a WCF net.tcp service that's hosted in IIS7.5.

On the service side, I have the following binding config:

<binding name="OrgSyncService_NetTcpBinding" portSharingEnabled="true"
         transactionFlow="true" maxReceivedMessageSize="1048576000"
         openTimeout="00:01:00" receiveTimeout="00:15:00" sendTimeout="00:15:00">
    <security mode="Transport">
        <transport clientCredentialType="Windows"
                   protectionLevel="EncryptAndSign"/>
    </security>
    <readerQuotas maxStringContentLength="1073741824" />
    <reliableSession enabled="true" inactivityTimeout="00:15:00" />
</binding>

As you can see, all relevant timeouts are 15 minutes. On the client-side, the binding configuration is as follows:

<binding name="NetTcpBinding_OrgSyncService" closeTimeout="00:01:00"
         openTimeout="00:01:00" receiveTimeout="00:15:00" sendTimeout="00:15:00"
         transactionFlow="true" transferMode="Buffered"
         transactionProtocol="OleTransactions"
         hostNameComparisonMode="St开发者_高级运维rongWildcard" listenBacklog="10"
         maxBufferPoolSize="524288" maxConnections="10"
         maxReceivedMessageSize="1048576000">
    <readerQuotas maxDepth="32" maxStringContentLength="1073741824"
                  maxArrayLength="16384" maxBytesPerRead="4096"
                  maxNameTableCharCount="16384" />
    <reliableSession ordered="true" inactivityTimeout="00:15:00" enabled="true" />
    <security mode="Transport">
        <transport clientCredentialType="Windows"
                   protectionLevel="EncryptAndSign" />
        <message clientCredentialType="Windows" />
    </security>
</binding>

Again, all timeouts that I'm aware of are set to 15 minutes. Finally, the code that starts the transaction:

var options = new TransactionOptions
{
    IsolationLevel = IsolationLevel.ReadCommitted,
    Timeout = TimeSpan.FromMinutes(15)
};
using (var ts = new TransactionScope(TransactionScopeOption.Required, options))
{
    // Do transactional work.
    // Call web service.
    service.HandleSourceChanges(listOfChanges);
    ts.Complete();
}

The web service method itself has the following signature:

[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void HandleSourceChanges(IEnumerable<OrgSyncSourceChange> sourceChanges)
{ /* Handle changes and store them in the database. */ }

But, as I said, exactly 10 minutes after starting the transaction, it times out. I'm not sure it's the transaction itself that times out. It could be another component that times out that causes the transaction to time out.

What am I missing? Is there an IIS setting I don't know about? An MSDTC setting?


I found the solution myself after a long search. It turned out to be a default value in machine.config. There's a system.transaction section there with a default transaction timeout value of 10 minutes. This timeout overrides all other timeouts.

If you add the following to your machine.config (in my case in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config) you can modify this global timeout limit.

<system.transactions>
    <machineSettings maxTimeout="00:15:00" />
</system.transactions>

In this case I set it to 15 minutes.


Could it be the idle-time out setting in your App Pool in IIS? Maybe worth extending this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜