hertz
hertz copied to clipboard
使用etcd做服务中心,hertz做api层rpc调用kitex,过一段时间后hertz自动退出,麻烦看下这是哪里出了问题?
Describe the Question
api(hertz)调rpc, 可以成功调通,过一会之后,api打印 2024/04/15 10:29:16 remote or network error: default codec read failed: read tcp 127.0.0.1:49993->127.0.0.1:8888: wsarecv: An established connection was aborted by the software in your host machine. Debugger finished with the exit code 0
etcd版本:官网最新的 3.5.13
与 https://github.com/cloudwego/kitex/issues/932 相同
api 退出是不是因为,rpc 报错了,你的业务逻辑就退出了导致了...
rpc没有报错,我加了超时配置,但还是没有解决
func InitRpc() { r, err := etcd.NewEtcdResolver([]string{"127.0.0.1:2379"}) // r不应重复使用。 if err != nil { log.Fatal(err) } BasicCoreClient, err = basiccoreservice.NewClient( "playgo.basic.core", client.WithResolver(r), client.WithRPCTimeout(time.Duration(5)*time.Second), client.WithConnectTimeout(time.Duration(5)*time.Second)) if err != nil { panic(err) } }
目前看结论是这个