grpc-ecosystem / grpc-spring

Spring Boot starter module for gRPC framework.
https://grpc-ecosystem.github.io/grpc-spring/
Apache License 2.0
3.48k stars 816 forks source link

GrpcClient的断线重连 #851

Closed f1024557668 closed 1 year ago

f1024557668 commented 1 year ago

你好,请问,server端突然宕机了,然后重启后,客户端依然还是报未连接。客户端有什么配置可以保持重连吗?

ST-DDT commented 1 year ago

English


AFAIK the client should automatically reconnect. I noticed that some service-registries are kind of slow in detecting service unavailability and thus the requests get sent to the old server for up to a minute or so. If I remember my integration tests with these systems correctly, then nacos was the fastest. If you dont use a service discovery/discovery client, then I dont know the reason. Please ask grpc-java directly.

f1024557668 commented 1 year ago

The runtime environment was k8s,and the service with the DNS discovery.And now I found that the server been restarted,but the client was always UNAVAILABLE.I found the class ManagedChannelImplBuilder,if I use this class to set the method which names maxRetryAttempts,it will work?

ST-DDT commented 1 year ago

but the client was always UNAVAILABLE

If it is always unavailable, then that sounds like the address/port is wrong.

See also: https://yidongnan.github.io/grpc-spring-boot-starter/en/kubernetes.html

f1024557668 commented 1 year ago

Because I've not use the ManagedChannelImplBuilder,and I see the default setting retry times was five.So I guess maybe the server was cost too long time that the client have retried the limit?