Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

redis连接超时 #26

Closed
guojoa opened this issue Dec 24, 2020 · 12 comments
Closed

redis连接超时 #26

guojoa opened this issue Dec 24, 2020 · 12 comments

Comments

@guojoa
Copy link

guojoa commented Dec 24, 2020

redis设置无密码和有密码都测试了,都提示连接超时

2020-12-24 12:23:49,281 ERROR 21990 nodejs.ETIMEDOUTError: connect ETIMEDOUT
at Socket. (/home/guo/development/javascript/midwayjs/project/service-mw2/node_modules/_ioredis@4.19.4@ioredis/built/redis/index.js:308:37)
at Object.onceWrapper (events.js:421:28)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:486:12)
at Socket._onTimeout (net.js:483:8)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
errorno: "ETIMEDOUT"
code: "ETIMEDOUT"
syscall: "connect"
name: "ETIMEDOUTError"

@tkvern
Copy link
Member

tkvern commented Dec 24, 2020

启动的是哪个环境?配置 redis 的 IP 能正常访问吗

@tkvern
Copy link
Member

tkvern commented Dec 24, 2020

image
需要确认你的 Redis 服务已经启动

@guojoa
Copy link
Author

guojoa commented Dec 26, 2020

可以确定启动了,我单独创建一个项目,安装egg-redis后是正常的,以下是我的代码

import { Controller, Get, Provide } from '@midwayjs/decorator';
import { Context } from 'egg';

@provide()
@controller('/')
export class HomeController {
@get('/')
async home() {
return 'Hello Midwayjs!';
}

@get('/test')
async test(ctx:Context) {
console.log('ctx',await ctx.app.redis.get('a'));
const a = await ctx.app.redis.get('a')
return 'my test ' + a;
}
}
网页访问test方法能正常返回redis设置的值

@tkvern
Copy link
Member

tkvern commented Dec 28, 2020

image
我复现了你说的问题,一般这种情况,需要修改config文件中配置的IP

@guojoa
Copy link
Author

guojoa commented Dec 28, 2020

默认是127.0.0.1,我改成localhost,或192.168.1.x。还是不行

@tkvern
Copy link
Member

tkvern commented Dec 29, 2020

可能需要你自行排查下哪个环节有问题。

@NiBoTe
Copy link

NiBoTe commented Dec 31, 2020

我的也连不上Redis,都修改了也不行,不知道为啥

@tkvern
Copy link
Member

tkvern commented Dec 31, 2020

麻烦提供一下复现步骤

@NiBoTe
Copy link

NiBoTe commented Dec 31, 2020 via email

@NiBoTe
Copy link

NiBoTe commented Dec 31, 2020 via email

@NiBoTe
Copy link

NiBoTe commented Dec 31, 2020

我直接修改了 config.default.ts 文件中的配置
image

@tkvern
Copy link
Member

tkvern commented Dec 31, 2020

本地开发你需要修改config.local.ts这个文件

@tkvern tkvern added help wanted Extra attention is needed and removed help wanted Extra attention is needed labels Mar 25, 2021
@tkvern tkvern closed this as completed Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants