Hi All,
I am getting the below exception for the first attempt some times while executing the below query
context.<Enity>.FirstOrDefault(r => r.id == id);
Exception Log is here
"Npgsql.NpgsqlException: Exception while reading from stream ---> System.IO.IOException: Unable to read data from the transport connection: Connection timed out.
---> System.Net.Sockets.SocketException: Connection timed out\n at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)\n
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)\n
--- End of inner exception stack trace ---\n
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)\n at Npgsql.ReadBuffer.Ensure(Int32 count, Boolean dontBreakOnTimeouts)\n
--- End of inner exception stack trace ---\n at Npgsql.ReadBuffer.Ensure(Int32 count, Boolean dontBreakOnTimeouts)\n
at Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage)\n
at Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode)\n
at Npgsql.NpgsqlConnector.ReadExpecting[T]()\n
at Npgsql.NpgsqlDataReader.NextResultInternal()\n
at Npgsql.NpgsqlDataReader.NextResult()\n
at Npgsql.NpgsqlCommand.Execute(CommandBehavior behavior)\n
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderInternal(CommandBehavior behavior)\n
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, String executeMethod, IReadOnlyDictionary`2 parameterValues, Boolean closeConnection)\n
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)\n
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer)\n
at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_ShapedQuery>d__3`1.MoveNext()\n
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)\n
at lambda_method(Closure , QueryContext )\n
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_0`1.<CompileQueryCore>b__0(QueryContext qc)\n
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)\n
I am using the below project.json
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.1.0",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.1.1",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
**"Npgsql.EntityFrameworkCore.PostgreSQL": "1.1.0",**
"Microsoft.EntityFrameworkCore.Design": "1.1.1",
"System.Security.Claims": "4.3.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.AspNetCore.Authorization": "1.1.1",
"Microsoft.AspNetCore.Diagnostics.Abstractions": "1.1.1",
"Microsoft.IdentityModel.Tokens": "5.1.0",
"Microsoft.AspNetCore.Http.Abstractions": "1.1.1"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.1.0-preview4-final",
"imports": "portable-net45+win8+dnxcore50"
}
},
"frameworks": {
"netcoreapp1.1": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
I tried searching for the issue and found that the issue has been fixed in 3.1.2 https://github.com/npgsql/npgsql/issues/1100
and my npgsql version is 3.1.9 but I am still getting the issue. We have installed postgres in azure container. I am not sure if this will be a problem..
can any one help me on this ????
Npgsql is telling you that there was a timeout - this could be the result of your query taking too long to run, an overloaded server, or some network issue (e.g. dropped connection). It is unlikely to be an issue with Npgsql itself. Try running the same SQL from the command-line to see how long it is taking and compare the results. You may need to increase the timeout (CommandTimeout on the connection string) or disable it entirely (by specifying 0), although the default timeout of 30 seconds should be more than sufficient for normal applications.
Am going to close this as unrelated to Npgsql, but if you provide more information that points to Npgsql I'll reopen and we can discuss.
Stop the server, and restart it. It solved mine.
In my case (Npgsql 3.2.2.0), what solved was removing comment (description) from the schema where the table is in...
I've noticed that schemas that has no description was updating the edm with no problem, so I removed the description from the schema to test and "voila"...
I hope it helps someone..
Greetings from Itu/SP/Brasil!! kkkkkkk - wideweb.com.br
Thanks @roji for support...
Most helpful comment
Npgsql is telling you that there was a timeout - this could be the result of your query taking too long to run, an overloaded server, or some network issue (e.g. dropped connection). It is unlikely to be an issue with Npgsql itself. Try running the same SQL from the command-line to see how long it is taking and compare the results. You may need to increase the timeout (
CommandTimeout on the connection string) or disable it entirely (by specifying 0), although the default timeout of 30 seconds should be more than sufficient for normal applications.Am going to close this as unrelated to Npgsql, but if you provide more information that points to Npgsql I'll reopen and we can discuss.