Laravel queue process timeout error

PhpSymfonyLaravelTimeoutQueue

Php Problem Overview


I'm on Laravel using php artisan queue:listen to run queued jobs. One of these jobs is fairly involved and takes a long time, and so I'm getting the following error:

[Symfony\Component\Process\Exception\ProcessTimedOutException]                                                                                                                                                                              
The process ""/usr/local/Cellar/php55/5.5.14/bin/php" artisan queue:work  
--queue="QUEUE_URL" --delay=0 --memory=128 --sleep=3 --tries=0" 
exceeded the timeout of 60 seconds.

I know that I could run queue:listen with an arbitrarily high timeout value, but that's not ideal, as I do want it to time out in the event that some process is actually unreseponsive. I tried regularly calling set_time_limit(60) within the function called by the job, but that did not solve my problem.

I found a thread online mentioning Symfony\Component\Process\Process->setTimeout(null), but I don't know how to access that process object, or if that would even fix the issue.

Any help would be much appreciated.

Php Solutions


Solution 1 - Php

Adding --timeout=0 worked for my set up.

UPDATE: The entire command would therefore be php artisan queue:listen --timeout=0.

Hope this helps.

Solution 2 - Php

After investing much time I got the solution

Add below line in Job class and your job run without time out, even if you put the job in a crontab entry

public $timeout = 0;

Solution 3 - Php

This is a known bug in Laravel v5.3:

You should upgrade to v5.5 to fix this problem.

Another way is hacking the source code as explained here

Solution 4 - Php

A queue is performed mainly for the requests which take a lot of time to get done link sending mail in bulk, import data queue jobs run in the background. it improves our web app performance too. If we don't set timeout it takes default 60 Sec. the time interval and if we set timeout as a 0, it means we set infinite timeout the request is continuously run till it won't complete. To set the timeout, we have to run this command: php artisan queue:listen --timeout=0

Here is the reference link of official document: https://laravel.com/docs/8.x/queues

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWill DurneyView Question on Stackoverflow
Solution 1 - PhpDavid LemayianView Answer on Stackoverflow
Solution 2 - PhpAnmol MouryaView Answer on Stackoverflow
Solution 3 - PhpMostafa LavaeiView Answer on Stackoverflow
Solution 4 - PhpJeff HarveyView Answer on Stackoverflow