Hello,
First I am not sure this is a lumen specific error or a Laravel error too.
I have an app running on laravel (5.1) which dispatch jobs, handled by a lumen (5.1) worker.
I have multiple jobs running totally fine, however, if a job runs more than 60 seconds (I made some tests 59.75727891922s -> no error, 60.091041898727s -> error), I get the following :
`[2016-02-05 02:27:07] lumen.ERROR: exception 'PredisConnectionConnectionException' with message 'Error while reading line from the server. [tcp://127.0.0.1:6379]' in /var/www/app/vendor/predis/predis/src/Connection/AbstractConnection.php:168
Stack trace:
`
I stumble upon this issue https://github.com/nrk/predis/issues/121 but that wasn't that.
I have set an expire time of 120 seconds (https://github.com/laravel/framework/issues/8577), tried to add the 'read_write_timeout' => -1 parameter (http://stackoverflow.com/questions/11776029/predis-is-giving-error-while-reading-line-from-server) in database.php but nothing works.
For the record, some of the jobs use PhpRedis (no persistent connection) so I don't know if that may conflict with Predis (which seems not as all jobs running under 60s don't trigger the error).
My worker config in supervisor is the following :
[program:queue_processing]
command=php artisan queue:work --daemon --sleep=3 --queue=processing --tries=3
process_name=%(program_name)s_%(process_num)02d
numprocs=4
autostart=true
autorestart=true
Let me know if I can provide more infos.
It doesn't look like an issue with laravel, rather either with your server, or the packages we're using to communicate with redis.
try this
$redis = $app->make('redis'); // I am using this in route
$redis->set('stats', 'd');
same problem. any updates?
I encounter this problem also, for me it's happening while I'm trying the example from https://laravel.com/docs/5.5/redis#pubsub
after a few minutes of listening I get the error Error while reading line from the server. [tcp://127.0.0.1:6379] and the process terminated.
I had the same problem. Solved it by installing redis-server on ubuntu, and then starting it using redis-cli ping
@shmuelgutman I had the same problem with Laravel 5.4. Have you solve it?
@shmuelgutman I have fixed it! I've added
'read_write_timeout' => 0 in config/database.php
@freeman3s i have added,but nothing works. something not to do?
@maokeyang strange, it helped me
'read_write_timeout' => 0
You could also try to set the value to -1 to completely disable the timeout as mentioned by the author of Predis https://github.com/nrk/predis/issues/33#issuecomment-1395652. This was the case for me as I was running Laravel Horizon as a daemon script on the server.
You may also need to ensure you have the scheme set to tls if appropriate.
@shmuelgutman I have fixed it! I've added
'read_write_timeout' => 0in config/database.php
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
],
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
'read_write_timeout' => 0,
],
Most helpful comment
@shmuelgutman I have fixed it! I've added
'read_write_timeout' => 0in config/database.php