larksuite-oapi/src/main/java/com/larksuite/oapi/okhttp3_14/internal/http2/Http2Connection.java
void sendDegradedPingLater() {
    synchronized (this) {
      if (degradedPongsReceived < degradedPingsSent) return; // Already awaiting a degraded pong.
      degradedPingsSent++;
      degradedPongDeadlineNs = System.nanoTime() + DEGRADED_PONG_TIMEOUT_NS;
    }
    try {
      writerExecutor.execute(new NamedRunnable("OkHttp %s ping", connectionName) {
        @Override public void execute() {
          writePing(false, DEGRADED_PING, 0);
        }
      });
    } catch (RejectedExecutionException ignored) {
      // This connection has been closed.
    }
  }
/**
   * HTTP/2 can have both stream timeouts (due to a problem with a single stream) and connection
   * timeouts (due to a problem with the transport). When a stream times out we don't know whether
   * the problem impacts just one stream or the entire connection.
   *
   * <p>To differentiate the two cases we ping the server when a stream times out. If the overall
   * connection is fine the ping will receive a pong; otherwise it won't.
   *
   * <p>The deadline to respond to this ping attempts to limit the cost of being wrong. If it is too
   * long, streams created while we await the pong will reuse broken connections and inevitably
   * fail. If it is too short, slow connections will be marked as failed and extra TCP and TLS
   * handshakes will be required.
   *
   * <p>The deadline is currently hardcoded. We may make this configurable in the future!
   */
HTTP/2 can have both stream timeouts (due to a problem with a single stream) and connection
timeouts (due to a problem with the transport). When a stream times out we don't know whether
the problem impacts just one stream or the entire connection.

To differentiate the two cases we ping the server when a stream times out. If the overall
connection is fine the ping will receive a pong; otherwise it won't.

The deadline to respond to this ping attempts to limit the cost of being wrong. If it is too
long, streams created while we await the pong will reuse broken connections and inevitably
fail. If it is too short, slow connections will be marked as failed and extra TCP and TLS
handshakes will be required.

The deadline is currently hardcoded. We may make this configurable in the future!
HTTP / 2 can have both stream timeouts ( due to a problem with a single stream ) and connection timeouts ( due to a problem with the transport ) . When a stream times out we don ' t know whether the problem impacts just one stream or the entire connection . To differentiate the two cases we ping the server when a stream times out . If the overall connection is fine the ping will receive a pong ; otherwise it won ' t . The deadline to respond to this ping attempts to limit the cost of being wrong . If it is too long streams created while we await the pong will reuse broken connections and inevitably fail . If it is too short slow connections will be marked as failed and extra TCP and TLS handshakes will be required . The deadline is currently hardcoded . We may make this configurable in the future!
void sendDegradedPingLater() {
    synchronized (this) {
      if (degradedPongsReceived < degradedPingsSent) return; 
      degradedPingsSent++;
      degradedPongDeadlineNs = System.nanoTime() + DEGRADED_PONG_TIMEOUT_NS;
    }
    try {
      writerExecutor.execute(new NamedRunnable("OkHttp %s ping", connectionName) {
        @Override public void execute() {
          writePing(false, DEGRADED_PING, 0);
        }
      });
    } catch (RejectedExecutionException ignored) {
    }
  }
void sendDegradedPingLater ( ) { synchronized ( this ) { if ( degradedPongsReceived < degradedPingsSent ) return ; degradedPingsSent ++ ; degradedPongDeadlineNs = System . nanoTime ( ) + DEGRADED_PONG_TIMEOUT_NS ; } try { writerExecutor . execute ( new NamedRunnable ( "OkHttp %s ping" , connectionName ) { @ Override public void execute ( ) { writePing ( false , DEGRADED_PING , 0 ) ; } } ) ; } catch ( RejectedExecutionException ignored ) { } }
HTTP/2 can have both stream timeouts (due to a problem with a single stream) and connection
 timeouts (due to a problem with the transport).
HTTP / 2 can have both stream timeouts ( due to a problem with a single stream ) and connection timeouts ( due to a problem with the transport ) .
// Already awaiting a degraded pong. // This connection has been closed.