developmentseed / tipg

Simple and Fast Geospatial OGC Features and Tiles API for PostGIS.
https://developmentseed.org/tipg/
MIT License
153 stars 23 forks source link

Timeout error when creating ssl connection #72

Closed julianblue closed 1 year ago

julianblue commented 1 year ago

Hi,

I am trying to setup tipg with a standalone Postgres db. The db requires ssl. When trying to connect I get the following error

ERROR:    Traceback (most recent call last):
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/asyncio/tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/connect_utils.py", line 686, in _create_ssl_connection
    tr, pr = await loop.create_connection(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/starlette/routing.py", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/starlette/routing.py", line 566, in __aenter__
    await self._router.startup()
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/starlette/routing.py", line 654, in startup
    await handler()
  File "/data1/rsdata-stac-api/src/main/docker/tipg/tipg/main.py", line 98, in startup_event
    await connect_to_db(
  File "/data1/rsdata-stac-api/src/main/docker/tipg/tipg/db.py", line 89, in connect_to_db
    app.state.pool = await asyncpg.create_pool_b(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/pool.py", line 409, in _async__init__
    await self._initialize()
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/pool.py", line 437, in _initialize
    await first_ch.connect()
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/pool.py", line 129, in connect
    self._con = await self._pool._get_new_connection()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/pool.py", line 507, in _get_new_connection
    con = await connection.connect(
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/connection.py", line 2092, in connect
    return await connect_utils._connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/connect_utils.py", line 897, in _connect
    raise last_error
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/connect_utils.py", line 883, in _connect
    return await _connect_addr(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/connect_utils.py", line 770, in _connect_addr
    return await __connect_addr(params, timeout, False, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/connect_utils.py", line 827, in __connect_addr
    tr, pr = await compat.wait_for(connector, timeout=timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/site-packages/asyncpg/compat.py", line 56, in wait_for
    return await asyncio.wait_for(fut, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/local/DFPOC/blauju/anaconda3/envs/rsd-stac-api/lib/python3.11/asyncio/tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

ERROR:    Application startup failed. Exiting.

When connecting to the db with psql using the same variables all works well. Any idea what I am doing wrong ?

Thanks in advance.