Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Frequent errors from Predis saying "Error while reading line from the server" #366

Closed
srottem opened this issue Jul 13, 2018 · 10 comments
Closed

Comments

@srottem
Copy link

srottem commented Jul 13, 2018

Since moving from using the basic Laravel queue worker to Horizon I've started seeing frequent error messages in my log files when processing queued jobs. The error happens more frequently the more jobs are processed and appears to be Horizon related.

Predis\Connection\ConnectionException: Error while reading line from the server. [tcp://127.0.0.1:6379]
#34 vendor/predis/predis/src/Connection/AbstractConnection.php(155): onConnectionError
#33 vendor/predis/predis/src/Connection/StreamConnection.php(314): read
#32 vendor/predis/predis/src/Connection/AbstractConnection.php(120): readResponse
#31 vendor/predis/predis/src/Connection/AbstractConnection.php(112): executeCommand
#30 vendor/predis/predis/src/Client.php(331): executeCommand
#29 vendor/predis/predis/src/Client.php(314): __call
#28 vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(96): command
#27 vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(108): __call
#26 vendor/laravel/horizon/src/Repositories/RedisJobRepository.php(271): reserved
#25 vendor/laravel/horizon/src/Listeners/MarkJobAsReserved.php(36): handle
#24 vendor/laravel/horizon/src/Listeners/MarkJobAsReserved.php(0): call_user_func_array
#23 vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(379): Illuminate\Events\{closure}
#22 vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(209): dispatch
#21 vendor/laravel/horizon/src/RedisQueue.php(155): event
#20 vendor/laravel/horizon/src/RedisQueue.php(94): Laravel\Horizon\{closure}
#19 vendor/laravel/framework/src/Illuminate/Support/helpers.php(1041): tap
#18 vendor/laravel/horizon/src/RedisQueue.php(96): pop
#17 vendor/laravel/framework/src/Illuminate/Queue/Worker.php(246): getNextJob
#16 vendor/laravel/framework/src/Illuminate/Queue/Worker.php(107): daemon
#15 vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): runWorker
#14 vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): handle
#13 vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(0): call_user_func_array
#12 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): Illuminate\Container\{closure}
#11 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): callBoundMethod
#10 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): call
#9 vendor/laravel/framework/src/Illuminate/Container/Container.php(564): call
#8 vendor/laravel/framework/src/Illuminate/Console/Command.php(184): execute
#7 vendor/symfony/console/Command/Command.php(251): run
#6 vendor/laravel/framework/src/Illuminate/Console/Command.php(171): run
#5 vendor/symfony/console/Application.php(886): doRunCommand
#4 vendor/symfony/console/Application.php(262): doRun
#3 vendor/symfony/console/Application.php(145): run
#2 vendor/laravel/framework/src/Illuminate/Console/Application.php(89): run
#1 vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): handle
#0 artisan(37): null

Any thoughts?

@iShotFT
Copy link

iShotFT commented Jul 19, 2018

I'm having the same issue

@robclancy
Copy link
Contributor

robclancy commented Jul 19, 2018

I've had this since horizon was released. I just ignore it. Would be nice to know why it is happening.

EDIT: I also have the timeouts set to -1

@WillemRoman
Copy link

WillemRoman commented Aug 8, 2018

Same issue here. Did not manage to solve it yet. Would be awesome if somebody has a solution.
Also tried the timeouts -1

@iShotFT
Copy link

iShotFT commented Aug 17, 2018

I was able to solve this issue by changing the redis client from 'predis' to 'phpredis'.

This can be done in the /config/database.php file:

    'client' => 'phpredis',

    'default' => [

        'host' => env('REDIS_HOST', 'localhost'),

        'password' => env('REDIS_PASSWORD', null),

        'port' => env('REDIS_PORT', 6379),

        'database' => 0,

        'read_timeout' => 60,

After this change the error never appeared again.

@srottem
Copy link
Author

srottem commented Aug 27, 2018

Thanks iShotFT - good feedback. I would have preferred not to have to install phpredis but it sounds like it's the only fix available for now.

@robclancy
Copy link
Contributor

I don't want to change entire package for this but I guess I need to eventually. Annoying.

@driesvints
Copy link
Member

Hey everyone. Thanks for reporting this. I believe this might be related to laravel/framework#25039 so I don't think it's Horizon specific. Let's continue the discussion on the that issue. Feel free to reply back if you want to provide some additional feedback.

@srottem
Copy link
Author

srottem commented Oct 26, 2018

Yeah, I pulled Horizon from my project because of the errors, but it turns out they're still showing up.

@eithed
Copy link

eithed commented Apr 27, 2020

Given that laravel/framework#25039 was just closed, can you please reopen this.

@driesvints
Copy link
Member

@eithed like Taylor says: you'd need a cache failover system which is a feature request and should be implemented in Laravel itself.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants