For the complete documentation index, see llms.txt. This page is also available as Markdown.

net_listening - Ethereum

Example code for the net_listening JSON RPC method. Сomplete guide on how to use net_listening JSON RPC in GetBlock Web3 documentation.

This method returns whether the node is actively listening for network connections from peers. On managed RPC endpoints the response is virtually always true — the field's diagnostic value is highest on self-hosted nodes where isolation from the P2P network indicates a configuration or connectivity issue.

Parameters

This method takes no parameters.

Request

curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "net_listening",
    "params": [],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

const response = await axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'net_listening',
    params: [],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);
example.py
import requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'net_listening',
        'params': [],
        'id': 'getblock.io'
    }
)

print(response.json())

Response

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": true
}

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

boolean

true if the node is listening for peers, false if the P2P listener is disabled or unreachable

Use Cases

  • Node Health Probes: Basic reachability check as part of an endpoint availability monitor

  • Self-Hosted Node Diagnostics: Detect P2P isolation on a self-run node (managed endpoints won't return false in normal operation)

  • Load Balancer Health Checks: Simple boolean liveness probe for infrastructure-level health checks

Error Handling

Error Code
Message
Description

-32603

Internal error

Node's P2P listener status could not be determined

Web3 Integration

Last updated

Was this helpful?