首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
RedisPool在while true脚本中提示Connection refused
### 问题描述 RedisPool在while true脚本中提示Connection refused ### Swoole版本,PHP版本,以及操作系统版本信息 RedisPool在while true执行一段时间后提示Connection refused导致脚本无法继续,请问是有什么解决方案吗 ### 相关代码 ```php \Co\run(function () use ($config) { $redisPool = new \Swoole\Database\RedisPool((new RedisConfig) ->withHost($config['redis_host']) ->withPort($config['redis_port']) ->withAuth($config['redis_password']) ->withDbIndex($config['redis_db']) ->withTimeout(1) ); while (true) { $rd = $redisPool->get(); $rd->rPush('queue_1' , rand(1,1000)); $redisPool->put($rd); } }); ``` ### 你期待的结果是什么?实际看到的错误信息又是什么? 目前是开启supervisorctl重启脚本就好了,这个方法比较粗糙,不知道有没有什么合适的处理方式
发布于5年前 · 6 次浏览 · 来自
提问
C
CASON
### 问题描述 RedisPool在while true脚本中提示Connection refused ### Swoole版本,PHP版本,以及操作系统版本信息 RedisPool在while true执行一段时间后提示Connection refused导致脚本无法继续,请问是有什么解决方案吗 ### 相关代码 ```php \Co\run(function () use ($config) { $redisPool = new \Swoole\Database\RedisPool((new RedisConfig) ->withHost($config['redis_host']) ->withPort($config['redis_port']) ->withAuth($config['redis_password']) ->withDbIndex($config['redis_db']) ->withTimeout(1) ); while (true) { $rd = $redisPool->get(); $rd->rPush('queue_1' , rand(1,1000)); $redisPool->put($rd); } }); ``` ### 你期待的结果是什么?实际看到的错误信息又是什么? 目前是开启supervisorctl重启脚本就好了,这个方法比较粗糙,不知道有没有什么合适的处理方式
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2021-04-21
鲁飞
重连
赞
0
回复
2021-04-21
C
CASON
回复
鲁飞
好的 了解了
赞
0
回复