Laravel Predis Error while reading line from the server.

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
云数据库 Tair(兼容Redis),内存型 2GB
简介: 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_21158419/article/details/53610445 问题...
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_21158419/article/details/53610445

问题

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

 [Predis\Connection\ConnectionException]
 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

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
6月前
|
应用服务中间件 nginx
【报错】Failed to start A high performance web server and a reverse proxy server.
【报错】Failed to start A high performance web server and a reverse proxy server.
522 2
|
6月前
|
缓存 资源调度 JavaScript
server error: Preprocessor dependency “less“ not found. Did you install it?
server error: Preprocessor dependency “less“ not found. Did you install it?
534 0
|
Java
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
1089 0
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
|
2月前
|
监控
{"level":"warn","ts":"2023-11-07T00:35:53.400+0800","caller":"etcdserver/server.go:2048",&
{"level":"warn","ts":"2023-11-07T00:35:53.400+0800","caller":"etcdserver/server.go:2048",&
|
6月前
|
Python
RuntimeError: The Werkzeug web server is not designed to run in production. Pass allow_unsafe_werkze
RuntimeError: The Werkzeug web server is not designed to run in production. Pass allow_unsafe_werkze
187 0
|
API
Deliver by interactive card server error
Deliver by interactive card server error
77 2
|
缓存 前端开发 PHP
PHP - Laravel The stream or file “/storage/logs/.“ could not be opened in append
PHP - Laravel The stream or file “/storage/logs/.“ could not be opened in append
506 0
|
缓存 PHP 开发工具
Composer 更新时报错:PHP Fatal error: composerRequireac6b4…(): Failed opening required ‘…/src/helpers.php
Composer 更新时报错:PHP Fatal error: composerRequireac6b4…(): Failed opening required ‘…/src/helpers.php
218 0
Composer 更新时报错:PHP Fatal error:  composerRequireac6b4…(): Failed opening required ‘…/src/helpers.php
|
关系型数据库 MySQL
Error:Unable to find a match: mysql-community-server
Error:Unable to find a match: mysql-community-server
247 0