smallnest / rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
https://rpcx.io
Other
8.11k stars 1.17k forks source link

通过etcd做服务发现时,服务如果切换的话客户端不会自动切换 #708

Closed ChenMoGe2 closed 2 years ago

ChenMoGe2 commented 2 years ago

服务在A机器上进行部署,客户端通过etcd发现服务的目标IP并循环请求服务。将同一个程序部署在服务B上并关闭服务A,客户端不会发现服务B而是报错dial tcp (IPA):8997: connect: connection refused。

上述情况发生在客户端长时间启动之后,客户端如果刚启动的话不会发生上述现象可以成功访问到B的服务。现在怀疑是不是客户端和etcd断开了连接导致。客户端和etcd有没有重连机制呢

smallnest commented 2 years ago

客户端会一直监控着etcd. 你看看客户端有没有错误日志。是不是和etcd连接有问题?多长时间会出现问题? 你的rpcx版本是?

ChenMoGe2 commented 2 years ago

@smallnest 大概是一天零四个小时吧 2022/03/17 11:00:45 server.go:184: INFO : server pid:697155 2022/03/18 15:35:50 client.go:758: ERROR: rpcx: client protocol error:unexpected EOF 2022/03/18 15:37:19 connection.go:102: WARN : failed to dial server: dial tcp 10.64.4.15:8997: connect: connection refused 2022/03/18 15:37:19 connection.go:102: WARN : failed to dial server: dial tcp 10.64.4.15:8997: connect: connection refused 2022/03/18 15:37:19 connection.go:102: WARN : failed to dial server: dial tcp 10.64.4.15:8997: connect: connection refused 2022/03/18 15:37:19 connection.go:102: WARN : failed to dial server: dial tcp 10.64.4.15:8997: connect: connection refused 2022/03/18 15:37:19 connection.go:102: WARN : failed to dial server: dial tcp 10.64.4.15:8997: connect: connection refused

貌似是这个错误起决定性关键 2022/03/18 15:35:50 client.go:758: ERROR: rpcx: client protocol error:unexpected EOF,之后就一直报错了

rpcx版本是v1.6.4

Hanson commented 2 years ago

@ChenMoGe2 EOF 应该在这个 PR 里面解决了 #705

smallnest commented 2 years ago

没复现相关问题。 请使用最新的rpcx, client端失败模式配置成FailOver。 image https://github.com/rpcxio/rpcx-examples/tree/master/registry/etcdv3_restart

89trillion-fyz commented 1 year ago
discoveryCache   = make(map[string]rpxClient.ServiceDiscovery)
xclientCache     = make(map[string]rpxClient.XClient)

请问一下我可以再服务器启动的时候初始化好,后面循环获取map中的连接重复使用吗

smallnest commented 1 year ago

可以