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 时redis未就绪,等redis启动完成后,执行xreadgroup报错:Unable to read data from the transport connection: Connection timed out #485

Open
Justinacy opened this issue Sep 8, 2023 · 14 comments

Comments

@Justinacy
Copy link

No description provided.

@2881099
Copy link
Owner

2881099 commented Sep 8, 2023

该错误代表连接超时

@Justinacy
Copy link
Author

该错误代表连接超时

但是我并没有做什么,ping这个redis服务成功后就执行这个命令,然后就报超时,我应该做什么呢?重新new这个客户端

@Justinacy
Copy link
Author

该错误代表连接超时

但是我并没有做什么,ping这个redis服务成功后就执行这个命令,然后就报超时,我应该做什么呢?重新new这个客户端

重新new 后还是会报错的

@2881099
Copy link
Owner

2881099 commented Sep 8, 2023

ping 只是服务器能通,不一定是端口能通

如果 redis-server 没有改端口,默认是 6379

测试方法:

telnet 127.0.0.1 6379

@Justinacy
Copy link
Author

ping 只是服务器能通,不一定是端口能通

如果 redis-server 没有改端口,默认是 6379

测试方法:

telnet 127.0.0.1 6379

确认reids-server服务已经可用,但是之后操作xreadgroup 方法还是一直报Unable to read data from the transport connection: Connection timed out 像是连接池中连接超时了,可是我执行IsAvailable返回true了 ,有什么方法可以重置连接池连接吗?或者说我怎么样做才能让连接恢复正常,因为我要在代码中检测redis服务就绪,就绪后执行某些操作redis方法,有什么好的方式实现吗?

@Justinacy
Copy link
Author

务器能通,不一定是端

我跑的 csredis 的ping方法

@2881099
Copy link
Owner

2881099 commented Sep 8, 2023

xreadgroup 是阻塞的,是不是设置太长的超时时间了。

这个时间不能设置大于 Socket.ReceiveTimeout 的值,大约15秒

否则就触发了 socket receive timeout 错误。

@2881099
Copy link
Owner

2881099 commented Sep 8, 2023

如果想等待100秒,建议加个循环处理:

for (var i = 0; i < 10; i++)
xreadgroup 10秒

@Justinacy
Copy link
Author

Justinacy commented Sep 8, 2023

如果想等待100秒,建议加个循环处理:

for (var i = 0; i < 10; i++) xreadgroup 10秒

我现在把xreadgroup 阻塞时间改为1秒,在while循环中执行,还是报错csreids
错误【redis-server:6379/15】:Unable to read data from the transport connection: Connection timed out. at CSRedis.CSRedisClient.GetAndExecute[T](RedisClientPool pool, Func2 handler, Int32 jump, Int32 errtimes) at CSRedis.CSRedisClient.NodesNotSupport[T](String[] keys, T defaultValue, Func3 callback)
at CSRedis.CSRedisClient.XReadGroup(String group, String consumer, Int64 count, Int64 block, ValueTuple`2[] streams)
at UIH.Mcsf.MQ.Transfer.MQ.RedisMQ.<>c__DisplayClass0_1.b__1()

@Justinacy
Copy link
Author

请问在初始化redis连接时,redis-server没有就绪,过大概一分钟后就绪,三方库内部知道redis恢复了,为什么连接池里的连接都超时了,连接池默认连接数50个,这50个都不可用了,感觉这个问题的本质还是连接池里的连接在redis-server就绪后为什么都不可用了

@2881099
Copy link
Owner

2881099 commented Sep 8, 2023

哪个版本,不可用后需要等待恢复,每5秒检测一次

@Justinacy
Copy link
Author

3.8.669 这个版本 不可用后需要等待恢复,每5秒检测一次这个指的是redis-server 还是连接池里的连接

@2881099
Copy link
Owner

2881099 commented Sep 8, 2023

链接池里面,建议早切换到FreeRedis

@2881099
Copy link
Owner

2881099 commented Sep 8, 2023

FreeRedis对redis5.0以上版本支持更完善

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

2 participants