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

gRPC keepalive read ACK message in java code and GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA option #7237

Closed
abhilash93 opened this issue Jul 20, 2020 · 4 comments
Labels

Comments

@abhilash93
Copy link

abhilash93 commented Jul 20, 2020

We have TCP connections open for very long durations. I have enabled the keepalive on client side to detect the server disconnect scenario.

I have enabled
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS true
GRPC_ARG_KEEPALIVE_TIME_MS 120 seconds
GRPC_ARG_KEEPALIVE_TIMEOUT_MS 60 seconds

1) Is their way to read the keepalive acknowledgement message in java code of gRPC?

2) The channel are ideal for long time without data, I am trying to set the GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA to 0 in java. I am not finding a way to do it. Can you please suggest?

default value mentioned is 2
https://github.com/grpc/grpc/blob/master/doc/keepalive.md#FAQ

  NettyChannelBuilder.forAddress(ip, port)
                  .negotiationType(NegotiationType.TLS)
                  .sslContext(sslContext)
                  .overrideAuthority(certCN)
                  .keepAliveWithoutCalls(true)
                  .keepAliveTime(120, TimeUnit.SECONDS)
                  .keepAliveTimeout(60, TimeUnit.SECONDS)
                  .build();

Thanks

@ejona86
Copy link
Member

ejona86 commented Jul 20, 2020

GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA is gRPC C-specific. Java does not offer a configuration option for it. Why are you wanting it?

Java does have permitKeepAliveTime() and permitKeepAliveWithoutCalls() on server-side to adjust what the client is allowed to do.

@abhilash93
Copy link
Author

Example Use case:
we have channel that server sends messages once every 15 min.
We want to monitor the client side the channel is not disconnected due to network issues.
Only suggestion in java client side is to enable keep alive with these 3 options on nettybuilder
.keepAliveWithoutCalls(true)
.keepAliveTime(120, TimeUnit.SECONDS)
.keepAliveTimeout(60, TimeUnit.SECONDS)

will it work?
I see GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA is set zero to not limit the keepavlive request from client with out data exchange. The default is 2 keepalive message without data as explained in docs.

In java netty enabling the three options will it work to send keepalive more time even the data is not send by server frequently?

Is their way to read the keepalive acknowledgement message in java code of gRPC?

@ejona86
Copy link
Member

ejona86 commented Jul 21, 2020

For your use-case you only need to set keepAliveTime() and either keepAliveWithoutCalls(true) or idleTimeout(). You don't have to set keepAliveTimeout(). idleTimeout() puts the channel to "sleep" after a period of no RPCs; this closes the TCP connections so is lower resource usage but higher latencies. keepAliveWithoutCalls(true) is when the communication is latency-sensitive and you and the service are willing to pay the resources to keep it low-latency.

You shouldn't need to change GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA; it isn't what it sounds like at first glance (the name is right but imprecise; it is a workaround for certain scenarios). Instead you should change GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS.

Is their way to read the keepalive acknowledgement message in java code of gRPC?

No, there is not. If you want to see such acknowledgements you should use an RPC.

@ejona86
Copy link
Member

ejona86 commented Aug 4, 2020

Seems like this should be resolved. If that is not the case, comment, and it can be reopened.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants