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

A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - Undefined error: 0) #2640

Open
Oriu opened this issue Jul 2, 2024 · 5 comments
Labels
ℹ️ Needs more Info Issues that have insufficient information to pursue investigations 🆕 Triage Needed For new issues, not triaged yet.

Comments

@Oriu
Copy link

Oriu commented Jul 2, 2024

Using Microsoft.Data. SqlClient on MAC M1 MAX's rider connection to SqlServer query error,But it can be done on the window。

Code:
string connectionString = "Persist Security Info=True;TrustServerCertificate=True;Data Source=myaddress;User ID=myuserid;Password=mypassword;DataBase=mydbname";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand("SELECT * FROM myTable", connection))
{
command.ExecuteReader();
}
connection.Close();
}

Error message:
Microsoft.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - Undefined error: 0)
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
at Microsoft.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
at Microsoft.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
at Microsoft.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at SqlSugar.AdoProvider.GetDataReader(String sql, SugarParameter[] parameters)
at SqlSugar.AdoProvider.SqlQuery[T,T2,T3,T4,T5,T6,T7](String sql, Object parameters)
at SqlSugar.AdoProvider.SqlQuery[T](String sql, SugarParameter[] parameters)
at SqlSugar.AdoProvider.SqlQuery[T](String sql, Object parameters)
at TestWeb.Controllers.WeatherForecastAppService.PostProducts(TestPage testPage) in /Volumes/magic/MyWork/MyCode/xy.libcore/TestWeb/AppServices/WeatherForecastController.cs:line 333
ClientConnectionId:1366f45c-7f42-4d3a-bdec-98b0006a4e58

@chenxiang0114
Copy link

chenxiang0114 commented Jul 2, 2024

My Microsoft.Data.SqlClient already update to the version 5.2.1. but sqlserver not work
image

If I use 2.1.7, SQL Server can work completely normally, but upgrading to 5.2.0 5.2.1 will not work

.net8

@arellegue
Copy link
Contributor

Thank you for reporting this issue. Could you provide an event trace log, please. You can find more information at:
https://learn.microsoft.com/en-us/sql/connect/ado-net/enable-eventsource-tracing?view=sql-server-ver16

Please provide 2 event trace logs, one from 2.1.7 and one for 5.2.1 versions of the SqlClient driver.

Once, we receive the above information, we can begin our investigation.

@arellegue arellegue added ℹ️ Needs more Info Issues that have insufficient information to pursue investigations 🆕 Triage Needed For new issues, not triaged yet. labels Jul 2, 2024
@chenxiang0114
Copy link

nettrace.zip
my computer is MacOS, so I can only provide log files with the suffix. nettrace. Can you parse them? If it doesn't work, could you please inform me of other collection methods for Mac OS (the document you sent above seems to be from Windows)

@arellegue
Copy link
Contributor

The EventSource trace will work in Mac OS as long as you have dotnet SDK and runtimes installed for Mac OS.

https://learn.microsoft.com/en-us/dotnet/core/install/macos

@JRahnama
Copy link
Contributor

@chenxiang0114 there are several breaking changes between versions 2.1.7 and 5.2.1. The most important one is changing the default value of the connection string property Encrypt from false to true. If you do not have a certificate (it could be self-signed) for SQL/client authentication and your application is not in production, I suggest testing by adding Encrypt=false to your connection string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ℹ️ Needs more Info Issues that have insufficient information to pursue investigations 🆕 Triage Needed For new issues, not triaged yet.
Projects
Status: Needs More Info
Development

No branches or pull requests

4 participants