Re: connection timeout hint

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: connection timeout hint
Дата
Msg-id 652683.1701659411@sss.pgh.pa.us
обсуждение исходный текст
Ответ на connection timeout hint  (Jeff Janes <jeff.janes@gmail.com>)
Список pgsql-hackers
Jeff Janes <jeff.janes@gmail.com> writes:
> When one tries to connect to a server and port which is protected by a
> firewall, ones get messages like this:

> Unix:
> psql: error: connection to server at "192.168.0.26", port 5432 failed:
> Connection timed out
>         Is the server running on that host and accepting TCP/IP connections?

> Windows:
> psql: error: connection to server at "192.168.0.26", port 5432 failed:
> Connection timed out (0x0000274C/10060)
>         Is the server running on that host and accepting TCP/IP connections?

> But the hint given is unhelpful, and even positively misleading.

Well, maybe.  I think you're right that it would be useful to give
different hints for ETIMEDOUT and ECONNREFUSED, but sadly it seems
not uncommon for systems to just drop connection requests that
there's no listening process for.

Can we break down the possible cases any further?

* Target host doesn't exist or is down: could give ETIMEDOUT,
EHOSTDOWN, or EHOSTUNREACH.

* Host is up, but PG server is not running or not listening on that
socket: ideally ECONNREFUSED, but could be ETIMEDOUT if the local
firewall blocks it.

* Server is running, but firewall blocks reaching it: almost
certainly ETIMEDOUT.

Are there more cases?

The current hint is already reasonably on-point for EHOSTDOWN,
EHOSTUNREACH, ECONNREFUSED.  I agree it's too specific for
ETIMEDOUT, but what exactly would be a better message in view
of the multitude of possible causes?

> Is there some portable way to detect this cause of the connection problem
> (connection timeout)

No, I don't think so.  We have the kernel errno to work with
and little more.

            regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: [RFC] Clang plugin for catching suspicious typedef casting
Следующее
От: Thomas Munro
Дата:
Сообщение: gai_strerror() is not thread-safe on Windows