NServicebus sql connection problem

251 views
Skip to first unread message

Yanjie Zhou

unread,
Nov 16, 2015, 12:06:32 PM11/16/15
to Particular Software
Hi,

I find a problem when I try to open a sql connection in the NServicebus processing, but I receive an error like below:

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.

 

"The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)"

 

at System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMException comException)

   at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)

   at System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts)

   at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)

   at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)

   at System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)

   at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)

   at System.Data.ProviderBase.DbConnectionPool.PrepareConnection(DbConnection owningObject, DbConnectionInternal obj, Transaction transaction)

   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)

   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)

   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)

   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)

   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)

   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)

   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)

   at System.Data.SqlClient.SqlConnection.Open()

   at *********************************************.OpenConnectionString() 

And I did some research online, this only solution is like below:

https://social.msdn.microsoft.com/Forums/en-US/7172223f-acbe-4472-8cdf-feec80fd2e64/the-partner-transaction-manager-has-disabled-its-support-for-remotenetwork-transactions?forum=adodotnetdataproviders


After did the changes on the server and the error still occur, don't know how to deal with it..........


Could someone help to take a look about it?




Thank you



Yanjie Zhou

Yanjie Zhou

unread,
Nov 16, 2015, 12:06:34 PM11/16/15
to Particular Software
Hi,

I add a sql connection open function when NServicebus is running and hope to write some document to the sql database. But when I debug the process I receive an error like below:


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.

 

"The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)"

 

at System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMException comException)

   at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)

   at System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts)

   at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)

   at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)

   at System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)

   at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)

   at System.Data.ProviderBase.DbConnectionPool.PrepareConnection(DbConnection owningObject, DbConnectionInternal obj, Transaction transaction)

   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)

   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)

   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)

   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)

   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)

   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)

   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)

   at System.Data.SqlClient.SqlConnection.Open()

   at **********************************.OpenConnectionString()


But after I change the settings on the server, I still get this error.

I run the open sql connection separately and it works fine. 

Hope someone can help.........



Thank you

Yanjie Zhou


weronik...@particular.net

unread,
Nov 18, 2015, 3:30:55 AM11/18/15
to Particular Software
Hi Yanjie,

As mentioned in the article it might be necessary to restart both client and server machines before changes are applied. Can you confirm you did that?
You might also use our installers or PowershellScripts that should set everything up for you (http://docs.particular.net/platform/installer/offline#platform-installer-components-nservicebus-prerequisites).
If you don't need distributed transactions in your solution then you might also disable them in the endpoint configuration (see here http://docs.particular.net/nservicebus/messaging/transactions). They are enabled by default.

Hope that helps,
Weronika

Yanjie Zhou

unread,
Nov 18, 2015, 1:33:17 PM11/18/15
to Particular Software
Hi,

We already tried to restart the server and client and that doesn't work. We use the NServicebus version 4 and what we want is use the NServicebus handler to process the message and store the information to the SQL server. In this kind of situation can we disable the distributed transactions?


Thank you


Yanjie Zhou

weronik...@particular.net

unread,
Nov 19, 2015, 3:54:51 AM11/19/15
to particula...@googlegroups.com
Hi Yanjie,

It seems like still there is some prerequisite missing, it might be a firewall setting (see points 6-8 here https://technet.microsoft.com/en-us/library/cc753510(WS.10).aspx).
Also please make sure you restart the DTC service manually in the service manager after changing settings (you should get prompted from UI to restart DTC but it doesn't seem to always work).
Make sure all changes are applied on all machines that can get involved in this operation (database server, all servers that NServiceBus talks to (e.g. for transport or persistance) and your machine).
See here explanation of when the transaction is escalated to DTC http://docs.particular.net/nservicebus/messaging/transactions#transactions-ambient-transaction - is there any other machine in your setup that might also need those changes in settings?
Here's also a bunch of tips related to troubleshooting DTC issues http://docs.particular.net/nservicebus/operations/transactions-message-processing#distributed-transaction-coordinator.

If that doesn't help I'd need a bit more information:
- What's your set up (what transport and persistance are you using, are you using distributor or outbox, what's the physical setup of your system)
- The exception you posted - is it full stack trace or does it start somewhere in NServiceBus (e.g. like here https://groups.yahoo.com/neo/groups/nservicebus/conversations/topics/8502). If something is missing, please post the full stacktrace.
- Does everything work ok as long as you don't try to make that extra DB connection inside the handler?

Regarding my suggestion for disabling distributed transactions - that might be a bit premature suggestion on my side, let's try if any of the above can help to move us forward.

Weronika


On Monday, November 16, 2015 at 6:06:32 PM UTC+1, Yanjie Zhou wrote:

weronik...@particular.net

unread,
Nov 25, 2015, 2:57:05 AM11/25/15
to Particular Software
Hi Yanjie
Can you let me know if you managed to solve the issue?
Regards,
Weronika


On Monday, November 16, 2015 at 6:06:32 PM UTC+1, Yanjie Zhou wrote:
Reply all
Reply to author
Forward
0 new messages