Command procedure lost connection after long time

I have a process that takes a long time to complete, several hours, after about 2 hours I get this error.
Any suggestions?

ERROR: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
The SQL being executed was: SELECT data FROM cache WHERE id = ‘cb7b458ed1c5f7e8bf3cbde8fc585a45’ AND (expire = 0 OR expire >1651824918)

On my MySQL Server:
connect_timeout 100
wait_timeout 86400
interactive_timeout 86400