Skip to content

KeepAlive Ping Error Handling #738

@lyokato

Description

@lyokato

The following is an excerpt of the code that sets up KeepAlive written in lib/src/client/http2_connection.dart

      if (options.keepAlive.shouldSendPings) {
        keepAliveManager = ClientKeepAlive(
          options: options.keepAlive,
          ping: () {
            if (transport.isOpen) {
              transport.ping();
            }
          },
          onPingTimeout: () => transport.finish(),
        );
        transport.onFrameReceived
            .listen((_) => keepAliveManager?.onFrameReceived());
      }

We found that the above code occasionally threw an exception when calling the transport.ping().
Sometimes an HTTP/2 Connection error occurred, starting from the http2 library side.

Therefore, we have applied the following patch to prevent the exception from flying.

              transport.ping().catchError(() {
                shutdown();
              });

I am not sure if this is the appropriate way to fix the problem, but I will report it to you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions