Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello there! How to fix the error — The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors? #1263

Open
SergeyIlyinFirst opened this issue Oct 26, 2020 · 9 comments

Comments

@SergeyIlyinFirst
Copy link

SergeyIlyinFirst commented Oct 26, 2020

We encounter an error from time to time: The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors. Tool versions: .net 4.8, sql server 13.0.5820.21. This problem is Microsoft. Data. SqlClient of all versions, and with System. Data. SqlClient 4.8.2. We tried all the solutions that are listed on the forums. Not help. Other developers also have this problem. Our users suffer from this. We sincerely ask you to pay attention to this problem as soon as possible and report a solution. Thanks!

@mairaw
Copy link
Member

mairaw commented Oct 26, 2020

Seems like a duplicate of dotnet/SqlClient#85

@cheenamalhotra

@cheenamalhotra
Copy link
Member

cheenamalhotra commented Oct 26, 2020

Hi @SergeyIlyinFirst

Yes, this is a known issue and is tracked under dotnet/SqlClient#85.

If you have a .NET Framework application, please try enabling below app context switch and let us know.
(helpful info shared by a customer in dotnet/SqlClient#547 (comment))

AppContext.SetSwitch("Switch.System.Data.SqlClient.MakeReadAsyncBlocking", true);

@mairaw could you please transfer this issue to dotnet/SqlClient repository?
Thanks!

@novitito
Copy link

Hi,
We exactly get this error yesterday too, on a running .net core App in production with no particular reason...
If you can help us we are using Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3"

Is there Something to update ou modify ?
thanks
David

@cheenamalhotra
Copy link
Member

cheenamalhotra commented Oct 27, 2020

Hi @novitito

Please reference Microsoft.Data.SqlClient v1.1.3 or v2.0.1+ in your application to get fix (PR #557 and PR #550) for same issue in .NET Core applications.

If you continue to encounter issue with the updated driver, please wrap a repro application with latest driver version and provide us in Issue #85 in dotnet/sqlclient repository.

@SergeyIlyinFirst
Copy link
Author

@cheenamalhotra AppContext.SetSwitch("Switch.System.Data.SqlClient.MakeReadAsyncBlocking", true) - not help. The error is repeated.

@cheenamalhotra
Copy link
Member

cheenamalhotra commented Oct 29, 2020

@SergeyIlyinFirst

Let me clearly specify again as most information is in dotnet/SqlClient#85

For .NET Framework application:

If your application is using System.Data.SqlClient (.NET Framework), you need to use AppContext switch as under:
AppContext.SetSwitch("Switch.System.Data.SqlClient.MakeReadAsyncBlocking", true);

whereas if you're using Microsoft.Data.SqlClient (.NET Framework), you need to use this AppContext switch:
AppContext.SetSwitch("Switch.Microsoft.Data.SqlClient.MakeReadAsyncBlocking", true);
(also set by default)

For .NET Core application:

Use System.Data.SqlClient v4.8.2, OR use Microsoft.Data.SqlClient v1.1.3 or above.

Could you please confirm what runtime your application is using and if trying above options are not working in your case?

@cheenamalhotra
Copy link
Member

I'm not sure I follow 🤔

@SergeyIlyinFirst
Copy link
Author

SergeyIlyinFirst commented Oct 30, 2020

@cheenamalhotra we tested our app on a single server. The results in the pictures. There are fewer errors, but they are there. Testing other servers. There are options for the fix? Errors before correction 158, after 25. It should be zero.
https://yadi.sk/d/wwOkoYjNG7U7Gw

@SergeyIlyinFirst
Copy link
Author

@cheenamalhotra {
"error": {
"message": "The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors.",
"data": {
"Errors": [{
"Source": ".Net SqlClient Data Provider",
"Number": 4011,
"State": 3,
"Class": 16,
"Server": "sqlintao",
"Message": "The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors.",
"Procedure": "",
"LineNumber": 1
}],
"ClientConnectionId": "3fe3fc23-7d95-4320-96b3-16be93d81567",
"ClassName": "System.Data.SqlClient.SqlException",
"Message": "The incoming tabular data stream (TDS) protocol stream is incorrect. The MARS TDS header contained errors.",
"Data": {
"HelpLink.ProdName": "Microsoft SQL Server",
"HelpLink.ProdVer": "13.00.5820",
"HelpLink.EvtSrc": "MSSQLServer",
"HelpLink.EvtID": "4011",
"HelpLink.BaseHelpUrl": "http://go.microsoft.com/fwlink",
"HelpLink.LinkId": "20476"
},
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at System.Data.SqlClient.SqlCommand.<>c.b__180_0(Task1 result)\r\n at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()\r\n at System.Threading.Tasks.Task.Execute()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Dapper.SqlMapper.d__331.MoveNext() in /_/Dapper/SqlMapper.Async.cs:line 419\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": "8\n<ExecuteDbDataReaderAsync>b__180_0\nSystem.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Data.SqlClient.SqlCommand+<>c\nSystem.Data.Common.DbDataReader <ExecuteDbDataReaderAsync>b__180_0(System.Threading.Tasks.Task1[System.Data.SqlClient.SqlDataReader])",
"HResult": -2146232060,
"Source": ".Net SqlClient Data Provider",
"WatsonBuckets": null
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants