Open Street Map not printed using lizmap print tool

Hi all,
I have a project with the print tool correctly set, I’m able to print all my overlay layers but OSM as baselayer is not printed. If I try to make a wget request to a tile (eg. wget https://tile.openstreetmap.org/11/1078/740.png) I got a 403 forbidden error. Specifing the same user-agent of the getprint request from lizmap (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36), I got a 418 BLOCKED. If I modify the user-agent (eg. removing the Safari/537.36) I got 200 OK.

wget --debug https://tile.openstreetmap.org/11/1078/740.png  --> 403 forbidden
 
wget --debug --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36" https://tile.openstreetmap.org/11/1078/740.png --> 418 BLOCKED

wget --debug --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159" https://tile.openstreetmap.org/11/1078/740.png  --> 200 ok

The print tool works percfectly in other projects on a different server even if the get print request has the same user-agent and without any modification.

Any suggestions?

Thanks in advance!
Roberta

Do you have the option “Get images directly from WMS Server” set in your Lizmap QGIS Plugin for the OSM layer? I have not, and i can print OSM just fine!

I have just tried but nothing change! I cannot print OSM layer also with the option “Get images directly from WMS Server”

Thanks!

There have already been similar problems with WMS services due to the missing .cache directory.
This must be defined in a variable for the QGIS server (under Apache). And the directory must be writable for www-data.

1 Like

Try to set the smallest map and layout with your OSM layers.

Do not set OSM in the baselayers group to make the tiles fetched from QGIS Server, and check all your QGIS server logs (verbose), any clue ?

Did you check the size of the file qgis-auth.db on the server ?

If I move my OSM layer out of the baselayer group the request returns status code = 200 but the OSM layer is not visible.

In the qgiserver.log file I have several lines like that

09:35:37 INFO WMS[3488056]: repeat tileRequest 1 tile 42(retry 2)

Followed by this line:

09:35:37 WARNING WMS[3488056]: Not logging more than 100 request errors.

Hi, I have just set a cache directory with proper rights for www-data but nothing change…

didn’t the cache directory exist before?
Was the QGIS server restarted after the changes?

Yes I created the directory and then restarted apache but unfortunately nothing change…

and the variable for the QGIS server is also set accordingly?
FcgidInitialEnv QGIS_SERVER_CACHE_DIRECTORY /home/qgis/.cache
(/home/qgis/.cache as an example for me)

yes, it is…

Can you check this file ?
You must find it, is-it in ~/.local/share/QGIS/QGIS3/profiles/default/, QGIS Server (same as desktop) is creating its own profile folder with all data inside.

The qgis-auth.db is 60 KB…

Where is-it located ? Does it have enough rights to be written now (by QGIS-Server) ? What is the last update date of this file ? Can you try to move it to see if the file is there again ?

Thank you for the hint, the qgis-auth.db file got the proper rights but the folder didn’t. I gave the write permissions to the folder and now OSM layer is correctly printed!