I am trying to understand how keepalive or idle connection works with gRPC. I have bidirectional streaming RPC, where I create session and do nothing so that there is no activity on the channel.
- If there is no activity, GRPC_ARG_KEEPALIVE_TIME_MS signal will be blocked (https://github.com/grpc/grpc/blob/master/doc/keepalive.md#faq) and connection will be closed after this interval, however, it does not terminate and I see keepalive ping is sent and received. why?
- If we do not set any params, is there any timeout after which connection will be automatically closed? If yes, how do I change this behaviour, which param?
What is happening here is that maybe GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS parameter is true that’s why it is sending the pings even without connection.
GRPC_ARG_KEEPALIVE_TIMEOUT_MS is controlling the timeout as written in the documentation:
You can manually adjust this parameter to control the timeout duration.
Set the GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS to false so it cannot send keepAlive pings when there is no active call.