阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js http2session.ping

      Node.js http2session.ping([payload, ]callback)

      新增于: v8.9.3

      • payload < Buffer> ||Optional ping payload.
      • callback < Function>
      • Returns: < boolean>

      Sends a PING frame to the connected HTTP/2 peer. A callback function must be provided. The method will return true if the PING was sent, false otherwise.

      The maximum number of outstanding (unacknowledged) pings is determined by the maxOutstandingPings configuration option. The default maximum is 10.

      If provided, the payload must be a Buffer, TypedArray, or DataView containing 8 bytes of data that will be transmitted with the PING and returned with the ping acknowledgment.

      The callback will be invoked with three arguments: an error argument that will be null if the PING was successfully acknowledged, a duration argument that reports the number of milliseconds elapsed since the ping was sent and the acknowledgment was received, and a Buffer containing the 8-byte PING payload.

      session.ping(Buffer.from('abcdefgh'), (err, duration, payload) => {
        if (!err) {
          console.log(`Ping acknowledged in ${duration} milliseconds`);
          console.log(`With payload '${payload.toString()}'`);
        }
      });
      

      If the payload argument is not specified, the default payload will be the 64-bit timestamp (little endian) marking the start of the PING duration.


      更多内容请参考:Node.js HTTP2,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录