Currently, we only allow to make another attempt to connect to postgresql if we get error 28000 while authenticating:
|
try |
|
{ |
|
await conn.Authenticate(username, timeout, async, cancellationToken); |
|
} |
|
catch (PostgresException e) |
|
when (e.SqlState == PostgresErrorCodes.InvalidAuthorizationSpecification && |
|
(sslMode == SslMode.Prefer && conn.IsSecure || sslMode == SslMode.Allow && !conn.IsSecure)) |
While this behavior aligns with pgjdbc, in some cases we might not get an error and instead fail with Exception while reading from stream. This happens due to postgresql bug on windows, where due to the way postgresql closes the connection, we're essentially racing with whether we'll be able to read pg error from the socket or not.
We can think about making it so we always make another attempt without ssl for any sort of error.
Currently, we only allow to make another attempt to connect to postgresql if we get error
28000while authenticating:npgsql/src/Npgsql/Internal/NpgsqlConnector.cs
Lines 591 to 597 in ae3309f
While this behavior aligns with pgjdbc, in some cases we might not get an error and instead fail with
Exception while reading from stream. This happens due to postgresql bug on windows, where due to the way postgresql closes the connection, we're essentially racing with whether we'll be able to read pg error from the socket or not.We can think about making it so we always make another attempt without ssl for any sort of error.