首页 > Laravel Predis Error while reading line from the server.

Laravel Predis Error while reading line from the server.

问题

Laravel说明文档中的 Redis 发布与订阅案例,命令行运行php artisan redis:subscribe 到60s自动断开并报错

 [PredisConnectionConnectionException]Error while reading line from the server. [tcp://127.0.0.1:6379]

解决

config/database.php配置文件中,找到redis配置项,添加一行如下

'redis' => ['cluster' => false,'default' => ['host' => env('REDIS_HOST', '127.0.0.1'),'password' => env('REDIS_PASSWORD', null),'port' => env('REDIS_PORT', 6379),'database' => 0,'read_write_timeout' => 0,//new],]

 

原因

据Predis作者在配置文件中说明,因为在底层网络资源上执行读取或写入操作时使用了超时,默认设置了timeout 为60s。

参考

https://github.com/nrk/predis/wiki/Connection-Parameters

转载于:https://www.cnblogs.com/canyuexiang/p/6240002.html

更多相关: