Skip to content

spring.grpc.client.default-channel.enable-keep-alive has no effect #383

@kutmk

Description

@kutmk

Is spring.grpc.client.default-channel.enable-keep-alive intended to control whether client keepalive PINGs are sent?
Even when this is set to false, HTTP/2 PING frames are still sent.

Configuration used:

spring:
  grpc:
    client:
      default-channel:
        enable-keep-alive: false
        keep-alive-time: 10s

Screenshot:

Image

PING frames are sent periodically even with default settings.
The explicit keepalive properties were set only for easier observation.

The suspected location is ClientPropertiesChannelBuilderCustomizer, where keepalive settings seem to be applied unconditionally:

mapper.from(channel.getKeepAliveTime()).to(durationProperty(builder::keepAliveTime));
mapper.from(channel.getKeepAliveTimeout()).to(durationProperty(builder::keepAliveTimeout));
mapper.from(channel.isKeepAliveWithoutCalls()).to(builder::keepAliveWithoutCalls);

enableKeepAlive is defined as a property, but it does not appear to be used to gate keepalive application.
Would it be necessary to guard this with enableKeepAlive, for example:

if (channel.isEnableKeepAlive()) {
    mapper.from(channel.getKeepAliveTime()).to(durationProperty(builder::keepAliveTime));
    mapper.from(channel.getKeepAliveTimeout()).to(durationProperty(builder::keepAliveTimeout));
    mapper.from(channel.isKeepAliveWithoutCalls()).to(builder::keepAliveWithoutCalls);
}

Thanks for taking a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions