Skip to content

eliminates unnecessary ping when the connection is idle #3380

@HuSharp

Description

@HuSharp

Version
master

Platform
Linux 5.4.0-154-generic #171-Ubuntu SMP Fri Jun 16 16:29:04 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Description
Setting PermitWithoutStream to false on the client side eliminates the need to send pings when the connection is idle.

otherwise output too many ping

can check code here https://github.com/grpc/grpc-go/blob/70f1a4045da95b93f73b6dbdd7049f3f053c0680/internal/transport/http2_server.go#L891-L894

grpc-client will check https://github.com/grpc/grpc-go/blob/70f1a4045da95b93f73b6dbdd7049f3f053c0680/internal/transport/http2_client.go#L1685-L1693

I tried this code:

maybe need to check idle here

fn maybe_ping(&mut self, cx: &mut task::Context<'_>, is_idle: bool, shared: &mut Shared) {
        match self.state {
            KeepAliveState::Scheduled(at) => {
                ...
                if !self.while_idle && is_idle {
                    trace!("keep-alive while idle disabled");
                    return;
                }
               ...
            }
            KeepAliveState::Init | KeepAliveState::PingSent => (),
        }
    }

I expected to see this happen: [explanation]
do not output too many ping

Instead, this happened: [explanation]
unnecessary ping from client side

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug. Something is wrong. This is bad!

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions