Node.js http2session.remoteSettings Method

Last Updated : 17 Aug, 2026

The http2session.remoteSettings property in Node.js provides the current HTTP/2 settings received from the remote peer. It allows applications to access configuration values that control how the remote endpoint communicates over the HTTP/2 session.

  • It provides the settings sent by the remote HTTP/2 endpoint.
  • It helps inspect configuration values that control the HTTP/2 session.
  • It returns the current remote settings as an object.

Syntax:

http2session.remoteSettings

Where

  • http2session: It represents an active HTTP/2 session.
  • remoteSettings: It returns the current settings received from the remote peer.

Return Value: It returns an object containing the current HTTP/2 settings received from the remote peer.

Example 1:

javascript
const http2 = require('http2');
const fs = require('fs');

// Private key and public certificate for access
const options = {
  key: fs.readFileSync('private-key.pem'),
  cert: fs.readFileSync('public-cert.pem'),
};

// Creating and initializing server
// by using http2.createServer() method
const server = http2.createServer(options);

server.on('stream', (stream, requestHeaders) => {
  stream.respond({ 
    ':status': 200, 
    'content-type': 'text/plain' 
  });

  stream.write('hello ');

  const http2session = stream.session;

  // Getting remote of this session
  // by using remoteSettings method
  const status = http2session.remoteSettings;

  stream.end("header table size : " 
    + status.headerTableSize);

  // Stopping the server
  // by using the close() method
  server.close(() => {
    console.log("server localSettings");
  })
});

server.listen(8000);

// Creating and initializing client
// by using tls.connect() method
const client = http2.connect(
    'http://localhost:8000');

const req = client.request(
  { ':method': 'GET', ':path': '/' });

req.on('response', (responseHeaders) => {
  console.log("status : " 
  + responseHeaders[":status"]);
});

req.on('data', (data) => {
  console.log('Received: %s ',
  data.toString().replace(/(\n)/gm, ""));
});

req.on('end', () => {
  client.close(() => {
    console.log("client localSettings");
  })
});

Output:

status : 200
Received: hello
Received: header table size : 4096
client localSettings
server localSettings

Example 2:

javascript
const http2 = require('http2');
const fs = require('fs');

// Private key and public certificate for access
const options = {
  key: fs.readFileSync('private-key.pem'),
  cert: fs.readFileSync('public-cert.pem'),
};

// Creating and initializing server
// by using http2.createServer() method
const server = http2.createServer(options);

server.on('stream', (stream, requestHeaders) => {

  // Getting session object
  // by using session method
  const http2session = stream.session;

  // Getting remote of this session
  // by using remoteSettings method
  const status = http2session.remoteSettings;

  stream.end("max frame size : " 
    + status.maxFrameSize);

  // Stopping the server
  // by using the close() method
  server.close(() => {
    console.log("server destroyed");
  })
});

server.listen(8000);

// Creating and initializing client
// by using tls.connect() method
const client = http2.connect(
    'http://localhost:8000');

const req = client.request(
  { ':method': 'GET', ':path': '/' });

req.on('data', (data) => {
  console.log('Received: %s ',
  data.toString().replace(/(\n)/gm, ""));
});

req.on('end', () => {
  client.close(() => {
    console.log("client destroyed");
  })  
});

Output:

Received: max frame size : 16384
client destroyed
server destroyed

Use Cases of http2session.remoteSettings Method

  • It can be used to inspect the HTTP/2 settings of the remote peer.
  • It helps monitor configuration changes during an HTTP/2 session.
  • It is useful for debugging and managing HTTP/2 connections.

Reference: https://nodejs.org/dist/latest-v12.x/docs/api/http2.html#http2_http2session_remotesettings

Comment

Explore