QGIS Server – Connection Timeout to /wfs3/collections Endpoint Explained

dockerogc-apiogc-api-featuresqgisqgis-server

This is the landing page of a QGIS server instance (camptocamp/qgis-server) which connects to a containerized PostGIS database to serve some vector data using the "OGC API – Features" (aka WFS3) protocol:

QGIS server landing page

And this is what happens (after ~2 seconds only) when I try to reach /wfs3/collections by clicking on "Feature collections" with Firefox 94.0:

The connection has timed out

The server at my.server.org is taking too long to respond.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

the log of the qgisserver docker service are as following at that precise moment:

qgisserver_1  | 20:35:43 WARNING Server[81]: The client requested an unsupported content type in Accept header: */*
qgisserver_1  | 1726 - 10.193.23.169 - - [22/Nov/2021:20:35:43 +0000] "GET / HTTP/1.1" 302 254 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
qgisserver_1  | 20:35:43 WARNING Landing Page[81]: QGIS_SERVER_LANDING_PAGE_PROJECTS_DIRECTORIES empty path: skipping.
qgisserver_1  | 20:35:43 WARNING Landing Page[81]: QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS empty connection: skipping.
qgisserver_1  | 8153 - 10.193.23.169 - - [22/Nov/2021:20:35:43 +0000] "GET /index.json HTTP/1.1" 200 557 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
qgisserver_1  | 5312899 - 10.193.23.169 - - [22/Nov/2021:20:35:40 +0000] "GET /wfs3/collections HTTP/1.1" 200 2030 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
qgisserver_1  | 20:37:16 WARNING Server[81]: The client requested an unsupported content type in Accept header: */*
qgisserver_1  | 1099 - 10.193.23.169 - - [22/Nov/2021:20:37:16 +0000] "GET / HTTP/1.1" 302 254 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
qgisserver_1  | 20:37:16 WARNING Landing Page[81]: QGIS_SERVER_LANDING_PAGE_PROJECTS_DIRECTORIES empty path: skipping.
qgisserver_1  | 20:37:16 WARNING Landing Page[81]: QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS empty connection: skipping.
qgisserver_1  | 1390 - 10.193.23.169 - - [22/Nov/2021:20:37:16 +0000] "GET /index.json HTTP/1.1" 200 557 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"

This is the definition of the qgisserver docker service:

version: '3.8'

services:
  ...
  qgisserver:
    image: "camptocamp/qgis-server:3.22"
    environment:
      - QGIS_PROJECT_FILE=/etc/qgisserver/my_qgis_project.qgs
      - PGSERVICEFILE=/etc/qgisserver/pg_service.conf
      - QGIS_SERVER_LOG_LEVEL=1
    restart: unless-stopped
    depends_on:
      - db
    ports:
      - "80:80"
    volumes:
      - ./my_qgis_projects:/etc/qgisserver

There is not much documentation on the docker hub page for that image.

What could the source of that problem be and how to solve it?

Here is the documentation: https://github.com/camptocamp/docker-qgis-server
I played around it for a while without any success.

Best Answer

I figured it out: the timeout was a direct consequence of my naive omission to open an SSH tunnel to the database:

$ ssh -f -N -L 5432:127.0.0.1:5432 user@server

(adapt URL, ports and credentials to your environment)

Related Question