Postgresql exception while connecting



Exception while connecting. No route to host #4231

Comments

Hi guys. This error falls from my service, has anyone encountered this ?!

The issue

System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
—> Npgsql.NpgsqlException (0x80004005): Exception while connecting —>
System.Net.Sockets.SocketException (113): No route to host
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException
(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.
Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|
283_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) at Npgsql.NpgsqlConnector.Con
nectAsync(NpgsqlTimeout timeout, CancellationToken cancellationToken) at Npgsql.NpgsqlConnector.ConnectAsync(NpgsqlTimeout timeout
, CancellationToken cancellationToken) at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async, CancellationTok
en cancellationToken) at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cance
llationToken) at Npgsql.ConnectorPool.<>c__DisplayClass38_0. d.MoveNext() — End of stack trace from pre
vious location — at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0. d.MoveNext() — End of
stack trace from previous location — at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAs
ync(Boolean errorsExpected, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.Relationa
lConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken) at Microsoft.EntityFrame
workCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected) at Mic
rosoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterO
bject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable
1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken) at Npgsql .EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func 4 operation, Func 4 verifySucceeded, CancellationToken cancellationToken) — End of inner exception stack trac e — at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult]( TState state, Func 4 operation, Func 4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrame workCore.Query.Internal.SingleQueryingEnumerable 1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.
Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable 1 asyncEnumerable, Cancel lationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOr DefaultAsync[TSource](IAsyncEnumerable 1 asyncEnumerable, CancellationToken cancellationToken) at WebService.Infrast
ructure.Repositories.TemplateRepo.GetAsyncByCode(String code)
in /src/WebService/WebService.Infrastructure/Repositories/TemplateRepo.cs:line
31 at WebService.Api.Commands.CreateDocComHandl.Handle(CreateDocumentCommand requ
est, CancellationToken cancellationToken) in /src/WebService/WebService.Api/Commands/CreateDocum
entCommand.cs:line 90 at MediatR.Pipeline.RequestExceptionProcessorBehavior 2.Handle(TRequest re quest, CancellationToken cancellationToken, RequestHandlerDelegate 1 next) at MediatR.Pipeline.Re
questExceptionProcessorBehavior 2.Handle(TRequest request, CancellationToken cancellationToken, Re questHandlerDelegate 1 next) at MediatR.Pipeline.RequestExceptionActionProcessorBehavior 2.Handle (TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate 1 next) at MediatR.
Pipeline.RequestExceptionActionProcessorBehavior 2.Handle(TRequest request, CancellationToken cance llationToken, RequestHandlerDelegate 1 next) at MediatR.Pipeline.RequestPostProcessorBehavior 2.Handle (TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate 1 next) at
MediatR.Pipeline.RequestPreProcessorBehavior 2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate 1 next) at WebService.Api.Controllers.WebServiceController.
CreateDocument(CreateDocumentCommand request)
in /src/WebService/WebService.Api/Controllers/WebServiceController.cs:line 36
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execut
e(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] argume
nts) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__
Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore
.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActio
nInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state
, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state,
Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awa
ited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task
task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Tas
k requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Core.AspNetCore.Builder.HttpEx
ceptionHandlerMiddleware.Invoke(HttpContext context)

Logs PostgrSql

2021-12-20 20: 38: 35.737 MSK [715] MESSAGE: Failed to receive data from client: Connection dropped by other side
2021-12-20 20: 38: 35.737 MSK [716] MESSAGE: Failed to receive data from client: Connection dropped by other side
2021-12-20 20: 38: 35.737 MSK [717] MESSAGE: Failed to receive data from client: Connection dropped by other side
2021-12-20 20: 38: 35.742 MSK [713] MESSAGE: Failed to receive data from client: Connection dropped by other side
2021-12-20 20: 38: 35.774 MSK [14866] MESSAGE: Failed to send data to the client: Channel break
2021-12-20 20: 38: 35.774 MSK [14866] IMPORTANT: connection to the client is lost
2021-12-20 20: 38: 35.790 MSK [9887] MESSAGE: Failed to send data to the client: Channel break
2021-12-20 20: 38: 35.790 MSK [9887] IMPORTANT: connection to the client is lost

Читайте также:  Python try file error

Further technical details

Microsoft.EntityFrameworkCore.Design Version=»5.0.6″
Npgsql.EntityFrameworkCore.PostgreSQL» Version=»5.0.6″

The text was updated successfully, but these errors were encountered:

Источник

Exception while reading from stream #4532

Comments

Before submitting

This repo is for Npgsql ADO.NET issues only. My code is working fine while debugging. We are deploying the code in PCF.
It throws an exception while trying open the connection to PostgreSQL Server in Linux.

Steps to reproduce

The code is having issues while trying to open the connection.

The issue

Describe what is not working as expected.

Npgsql.NpgsqlException (0x80004005): Exception while reading from stream
—> System.TimeoutException: Timeout during reading attempt
Npgsql.Internal.NpgsqlReadBuffer.g__EnsureLong|41_0(NpgsqlReadBuffer buffer, Int32 count, Boolean async, Boolean readingNotifications)
Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
Npgsql.Internal.NpgsqlConnector.g__OpenCore|191_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Npgsql.ConnectorPool.g__RentAsync|28_0(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Npgsql.NpgsqlConnection.g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken)

Further technical details

Npgsql version: 6.0.4
PostgreSQL version: 13.3
Operating system: Linux 8.x

Other details about my project setup:

The text was updated successfully, but these errors were encountered:

@arunsaho there are no details above — an exception message isn’t enough for us to help you. Please post a runnable code sample which triggers the issue, or at least provide more context.

string connString =
String.Format(
«Server=<0>;Username=<1>;Database=<2>;Port=<3>;Password=<4>;SSLMode=Prefer;Timeout=300;CommandTimeout = 300″,
Host,
User,
DBname,
Port,
Password);

Npgsql.NpgsqlException (0x80004005): Exception while reading from stream
—> System.TimeoutException: Timeout during reading attempt
Npgsql.Internal.NpgsqlReadBuffer.g__EnsureLong|41_0(NpgsqlReadBuffer buffer, Int32 count, Boolean async, Boolean readingNotifications)
Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
Npgsql.Internal.NpgsqlConnector.g__OpenCore|191_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Npgsql.ConnectorPool.g__RentAsync|28_0(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
Npgsql.NpgsqlConnection.g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken)
Npgsql.NpgsqlConnection.Open()

@arunsaho a network timeout during Open can occur for various reasons: you may have a firewall rule preventing the connection, there may be a misconfiguration, or if this happens intermittently, your network could be a bit flaky. In any case, this isn’t really related to Npgsql in any way — Npgsql simply establishes a standard TCP connection to the host and port you provide it.

If the error is reproducible and not intermittent, I’d recommend trying to connect to the same PostgreSQL (same host/port) from the same client machine where Npgsql is running, but from an external tool, e.g. the psql command-line tool. That would help isolate things.

Hello All — I’m getting a very similar error. We are using .net 6.0.7 Npgsql 6.0.5 AWS Arora Postgres 12.7 with RDS proxy. It is appearing in both our staging and prod environments. What is strange is it mainly appears in a simple query on a ver small table (prod

Читайте также:  Liquid sensor error перевод

20 rows staging

5 rows) and the query is based on primary key. Our load can be high on prod at times but is extremely low in staging.

query
select * from public.companies where

What is more strange is that it is not a repeatable event. In other words, it only happens sometimes. We have been looking for the issue for about a month now. Any help would be appreciated. It is always this query . very strange not to see it on random queries if it was a connection issue. We have check the Postgres logs and see no errors of note.

Источник

Exception while reading from stream error while connecting to npgsql #2969

Comments

while connecting to database from app i got Exception while reading from stream error message.
I tried my app in multiple devices all are working fine except one machine.
db is present in local machine. I just want to connect to it
Exception message:
Stack trace:

while connection.open() code is executing error produces

The text was updated successfully, but these errors were encountered:

Without knowing what are you doing, it’s impossible to understand what’s going wrong. Add a minimal reproducible example.

Please take a look at the issue template when open a new issue.

@YohDeadfall I have a c# app and postgres database. While I try to connect db from app I get this error message

Sorry, but there is no way in that case to help you. No code — no help.

@YohDeadfall I have updated the question with my code

Which driver version are you using? Have you checked other issues here?

@YohDeadfall I have updated the question please check

If this works on other machines, check who interrupts the network connection or kills the PostgreSQL backend. Other roots described by @Borja-Guiles in #2711 are possible too.

Server side logs could help in further investigations.

I got the same exception on local machine, it is reproduced for each database request:

And in postgres logs I see these errors:

Version npgsql: 4.1.3.1
I checked the credentials and database connection using the jetbrains database plugin, everything works.

@mbv and others, what we need is a minimal code sample that allows us to reproduce the error. Without that there is nothing we can do; I also propose trying the same code sample against a different PostgreSQL instance, or on another machine.

Seems interesting, I have created another docker container with postgres, and restore backup. And it works, I don’t get exceptions. But if I set pointing to previous posgres I still have exception every query to database. In code there is nothing spetific I left only fetch one record from table using LINQ.
I can’t understand what can be differrent, both containers created from one configuration file.

You can use Wireshark to sniff traffic and compare it. Having a diff could help us narrow the problem.

@YohDeadfall Thank you, Wireshark helped me! This is my bad. The issue is with my local infrastructure. I ran the web application with the same port as used by the docker container postgres.

Читайте также:  Unknown envelope error e0031 wilcom

Источник

5.0.4: Npgsql.NpgsqlException (0x80004005): Exception while reading from stream #3495

Comments

we are experiencing the same exception described in npgsql/efcore.pg#1599 however after including the Npgsql 5.0.4 to our project, the issue still remains. It was first noticed after we upgraded to 5.0.3 version, all was working before with V3.1.2.

In our case the table we insert in has a trigger on it. If 2 or more items are saved together the timeout exception is thrown (when 1 item is saved at a time it works just fine).

Npgsql version: 5.0.4
PostgreSQL version: 12
Operating system: Windows 10

The text was updated successfully, but these errors were encountered:

Are you saying that took a try of the package from the MyGet feed? Could you provide a runnable repro?

Not from MyGet feed. In our project we are using nuget packages. Currently we have

Npgsql.EntityFrameworkCore.PostgreSQL 5.0.2 which is dependent on Npgsql (>= 5.0.2)
NpgsqlBulk.EFCore 0.9.0 which is dependent on Npgsql.EntityFrameworkCore.PostgreSQL (>= 3.1.0)

We did not have the Npgsql referenced explicitly, but even when we do that the issue is not resolved.

We have a Customer and Contacts tables with relation one to many. On the Contacts table there is a primary contact flag. When the flag is set to true for a Contact a trigger makes changes to both the related parent Customer as well as properties in Other contacts. The trigger is «FOR EACH ROW»

We want to create Contacts in bulk (saving a batch of 1000 at a time) which fails with the error bellow (thrown by context.SaveChangesAsync)

System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. —> Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. —> Npgsql.NpgsqlException (0x80004005): Exception while reading from stream —> System.TimeoutException: Timeout during reading attempt at Npgsql.NpgsqlConnector.g__ReadMessageLong|194_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage) at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken) at Npgsql.EntityFrameworkCore.PostgreSQL.Update.Internal.NpgsqlModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken) — End of inner exception stack trace — at Npgsql.EntityFrameworkCore.PostgreSQL.Update.Internal.NpgsqlModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable 1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable 1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable 1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList 1 entriesToSave, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func 4 operation, Func 4 verifySucceeded, CancellationToken cancellationToken) — End of inner exception stack trace — at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func 4 operation, Func 4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at SFA.Db.AppDbContext.SaveChangesAsync(Int64 userId)

Before migration to .Net 5 and upgrading the Npgsql references the same code was working without a problem.

I’m sorry but we might not be able to provide runnable repo. I’ll try to check if we can.

Источник

Оцените статью
toolgir.ru
Adblock
detector