grpc-spring
grpc-spring copied to clipboard
Client Connection Status
Hello everyone I would like to get the connection status of the grpc client, is it possible?
Example:
- grpc client is online
- grpc server starts after 5 minutes
When my grpc client reconnects, it must send a message to the server.
Thank you for your support
This might help you: ManagedChannel#notifyWhenStateChanged(...)
@ST-DDT Can you show me an example of grpc-spring-boot-starter?
Unfortunately, there is currently no way in this library to get the ManagedChannel
instance without using a little bit of a workaround. You have to extend AbstractChannelFactory
(or the existing implementations) and extend the newManagedChannel
or watchConnectivityState
method to your needs (or use reflection to access the channels
field). This will probably change in a future version, but there isn't a timeline for that yet.
When my grpc client reconnects, it must send a message to the server.
What is the purpose of that message?
Is it used for authentication? Then you might be better of with using CallCredentials
.
I'm not sure, whether grpc supports connection level authentication.
Please note, that the client doesn't just reconnect by itself, AFAICT it has to be triggered by a new call. It might be better to just setup a scheduled task, that sends the request.
Is it enough to setup intermediateconnecttimeout to non-zero for channel and set grpc.cleint.
Is it enough to setup intermediateconnecttimeout to non-zero for channel and set grpc.cleint..enableKeepAlive propery to true to guarantee that channel is always warmed up ?
I'm not sure, maybe you should ask this question over at grpc-java.
actually i also suffer from not getting managed channel with ease like someService.getChannel().getState(true) to ensure channel is up before call.
I plan to adjust the channel factory to allow the users to access the underlying managed channels. Why do you need to ensure the channel is up before the call?
I need it for deterministic deadline.
Unfortunately, there is currently no way in this library to get the
ManagedChannel
instance without using a little bit of a workaround. You have to extendAbstractChannelFactory
(or the existing implementations) and extend thenewManagedChannel
orwatchConnectivityState
method to your needs (or use reflection to access thechannels
field). This will probably change in a future version, but there isn't a timeline for that yet.When my grpc client reconnects, it must send a message to the server.
What is the purpose of that message? Is it used for authentication? Then you might be better of with using
CallCredentials
. I'm not sure, whether grpc supports connection level authentication.Please note, that the client doesn't just reconnect by itself, AFAICT it has to be triggered by a new call. It might be better to just setup a scheduled task, that sends the request.
Anyone tried this ? some sample code ?