efcore: A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)
Hi All,
In our production environment we see sporadic exceptions stating A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable).
At the moment we’re using a pretty simple connection string:
Server=172.24.32.7;Database=GetYourPet_1_1_0;User Id=***;Password=***;MultipleActiveResultSets=true
The database server is a separate machine from the web server, so there is networking involved. So I’m not sure why the connections go down in the first place, but then I’m wondering if there’s a way to catch this exception more generically and retry? And / or should we have more specific settings in the connection string about the size of the connection pool?
Sort of desperate here… any help would be great.
If you are seeing an exception, include the full exceptions details (message and stack trace).
Exception message: A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)
Stack trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) ~
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) ~
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error) ~
at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() ~
at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() ~
at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer() ~
at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value) ~
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) ~
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() ~
at System.Data.SqlClient.SqlDataReader.get_MetaData() ~
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) ~
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) ~
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) ~
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) ~
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) ~
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, String executeMethod, IReadOnlyDictionary`2 parameterValues, Boolean closeConnection) ~
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues) ~
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer) ~
at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func`2 operation, Func`2 verifySucceeded, TState state) ~
at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext() ~
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source) ~
at lambda_method(Closure , QueryContext ) ~
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_0`1.<CompileQueryCore>b__0(QueryContext qc) ~
at GetYourPet.Services.MeetUpService.Get(String adopterUserId, Int32 petId, ApplicationUserRole applicationUserRole) in D:\a\1\s\GetYourPet\src\GetYourPet\Services\MeetUpService.cs:line 45 ~
at GetYourPet.Controllers.MeetUpsController.Get(String adopterUserId, Int32 petId) in D:\a\1\s\GetYourPet\src\GetYourPet\Controllers\MeetUpsController.cs:line 63
Steps to reproduce
There are no deterministic steps to reproduce
line 45 from MeetUpService.cs:
MeetUp meetUp = _applicationDbContext.MeetUps.Where(mu => mu.AdopterUserId == adopterUserId && mu.PetId == petId).FirstOrDefault();
Further technical details
EF Core version: 1.1.0 Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Windows Server 2012 R2 IDE: Visual Studio 2015 w/ Update 3 (but that’s just what we develop with… the issue is occurring in our production environment)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (10 by maintainers)
After removing “MultipleActiveResultSets=true”, this issue was resolved for .NetCore 3.1
In our case, the issue “Physical connection is not usable” appeared only if MultipleActiveResultSets=true. The issue as been fixed by our customer by removing the “network packet analyzer” (In french: analyseur de trames réseau)