Skip to content

GRPC server side keepalive doesn't work as expected #2953

@zabranskiy

Description

@zabranskiy

Problem description

GRPC server doesn't destroy a connection after 'Ping timeout passed without response', instead it runs session.close() and the connection keeps hanging.

Reproduction steps

I started server, sent 1 request to grpc and moved client process to SIGSTOP state after first 'Received ping response'. I expect that after 'Ping timeout passed without response' underlying http2 session should be destroyed.

server.js:1157

keepaliveTimer = setTimeout(() => {
    clearKeepaliveTimeout();
    this.keepaliveTrace('Ping timeout passed without response');
    this.trace('Connection dropped by keepalive timeout');
    sessionClosedByServer = true;
    session.close(); // <-- here the problem
}, this.keepaliveTimeoutMs);

Environment

  • OS name, version and architecture: macOS Sequoia/arm64
  • Node version v22.11.0
  • Node installation method npm
  • Package name and version @grpc/[email protected]

Additional context

server options:
'grpc.keepalive_time_ms': 10e3,
'grpc.keepalive_timeout_ms': 5e3,
'grpc.keepalive_permit_without_calls': 1,

D 2025-05-08T14:09:12.787Z | v1.13.3 94805 | server | (1) Server constructed
D 2025-05-08T14:09:12.789Z | v1.13.3 94805 | server | (1) bindAsync port=0.0.0.0:8803
D 2025-05-08T14:09:12.790Z | v1.13.3 94805 | dns_resolver | Resolver constructed for target dns:0.0.0.0:8803
D 2025-05-08T14:09:12.790Z | v1.13.3 94805 | backoff | {0} constructed initialDelay=1000 multiplier=1.6 jitter=0.2 maxDelay=120000
D 2025-05-08T14:09:12.790Z | v1.13.3 94805 | backoff | {0} runOnce()
D 2025-05-08T14:09:12.790Z | v1.13.3 94805 | backoff | {0} runTimer(delay=1000)
D 2025-05-08T14:09:12.790Z | v1.13.3 94805 | dns_resolver | Returning IP address for target dns:0.0.0.0:8803
D 2025-05-08T14:09:12.791Z | v1.13.3 94805 | backoff | {0} stop()
D 2025-05-08T14:09:12.791Z | v1.13.3 94805 | backoff | {0} reset() running=false
D 2025-05-08T14:09:12.793Z | v1.13.3 94805 | server | (1) Attempting to bind 0.0.0.0:8803
D 2025-05-08T14:09:12.795Z | v1.13.3 94805 | server | (1) Successfully bound 0.0.0.0:8803
D 2025-05-08T14:09:16.211Z | v1.13.3 94805 | server | (1) Connection established by client 127.0.0.1:59845
D 2025-05-08T14:09:16.211Z | v1.13.3 94805 | keepalive | (1) Starting keepalive timer for 10000ms
D 2025-05-08T14:09:16.213Z | v1.13.3 94805 | server_call | Received call to method ...
D 2025-05-08T14:09:16.213Z | v1.13.3 94805 | server_call | Request to ...
D 2025-05-08T14:09:16.214Z | v1.13.3 94805 | server_call | Request to ...
2025-05-08T14:09:16 [info] client 127.0.0.1:59845/1e543c95 connected
D 2025-05-08T14:09:16.217Z | v1.13.3 94805 | server_call | Request to ...
D 2025-05-08T14:09:26.213Z | v1.13.3 94805 | keepalive | (1) Sending ping with timeout 5000ms
D 2025-05-08T14:09:26.214Z | v1.13.3 94805 | keepalive | (1) Received ping response
D 2025-05-08T14:09:26.214Z | v1.13.3 94805 | keepalive | (1) Starting keepalive timer for 10000ms
D 2025-05-08T14:09:36.216Z | v1.13.3 94805 | keepalive | (1) Sending ping with timeout 5000ms
D 2025-05-08T14:09:41.217Z | v1.13.3 94805 | keepalive | (1) Ping timeout passed without response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions