Random "Connection refused" on Linux
See original GitHub issueHello, we experience random SocketExceptions on all Linux VMs with pgBouncer:
System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state)
at System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state, Boolean flowContext)
at System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1](Func`4 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, Object state, TaskCreationOptions creationOptions)
at Npgsql.NpgsqlConnector.ConnectAsync(NpgsqlTimeout timeout, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<<Open>g__OpenLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at PgBouncePinger.Program.Main(String[] args)
We use host=localhost
, and tracing shows that error is related to [::1], because issue is not encountered then using host=127.0.0.1
.
Trace:
USUAL TRACE: TRACE Opening connection… TRACE Opening connection… TRACE Attempting to connect to [::1]:6543 TRACE Failed to connect to [::1]:6543 TRACE Attempting to connect to 127.0.0.1:6543 TRACE Socket connected to localhost:6543 TRACE Authenticating…
RANDOM ERROR: TRACE Opening connection… TRACE Opening connection… TRACE Attempting to connect to [::1]:6543 ERROR Breaking connector TRACE Cleaning up connector TRACE Closing connector
TRUE CONNECTION REFUSED (port not open): TRACE Opening connection… TRACE Opening connection… TRACE Attempting to connect to [::1]:6543 TRACE Failed to connect to [::1]:6543 TRACE Attempting to connect to 127.0.0.1:6543 TRACE Failed to connect to 127.0.0.1:6543 ERROR Breaking connector TRACE Cleaning up connector TRACE Closing connector
Maybe, possible solution would be to move this line into try
block below.
Issue Analytics
- State:
- Created 5 years ago
- Comments:23 (11 by maintainers)
100%. I can even use psql.
On Sunday, March 1, 2020, Shay Rojansky notifications@github.com wrote:
– Jerod Venema
@jvenema can you please submit a runnable sample for that?