http2session.setLocalWindowSize(windowSize)
windowSize<number>
设置本地端点的连接级窗口大小。
windowSize 是要设置的总窗口大小,而不是增量。
🌐 Sets the local endpoint's connection-level window size.
The windowSize is the total window size to set, not
the delta.
增加会立即生效,但减少只有在已经向对等方通告的窗口被使用完后才会生效,因为已经通告的窗口无法收回。如果想在连接开始时使用比默认值更小的窗口,可以在创建服务器或客户端会话时设置connectionWindowSize选项。
🌐 Increases take effect immediately, but decreases only apply as the window
already advertised to the peer is consumed, since a window that has been
advertised cannot be retracted. To use a window smaller than the default from
the start of the connection, set the connectionWindowSize option when
creating the server or client session instead.
import { createServer } from 'node:http2';
const server = createServer();
const expectedWindowSize = 2 ** 20;
server.on('session', (session) => {
// Set local window size to be 2 ** 20
session.setLocalWindowSize(expectedWindowSize);
});const http2 = require('node:http2');
const server = http2.createServer();
const expectedWindowSize = 2 ** 20;
server.on('session', (session) => {
// Set local window size to be 2 ** 20
session.setLocalWindowSize(expectedWindowSize);
});对于 http2 客户端,正确的事件是 'connect' 或 'remoteSettings'。
🌐 For http2 clients the proper event is either 'connect' or 'remoteSettings'.