net_listening - Polygon
Example code for the net_listening json-rpc method. Сomplete guide on how to use net_listening json-rpc in GetBlock.io Web3 documentation.
The net_listening method returns true if the client is actively listening for network connections.
Parameters
None
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"
}'import axios from 'axios';
const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';
const payload = {
jsonrpc: '2.0',
method: 'net_listening',
params: [],
id: 'getblock.io'
};
axios.post(url, payload, {
headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": true
}Response Parameters
Field
Type
Description
jsonrpc
string
JSON-RPC version (2.0)
id
string
Request identifier
result
varies
Boolean indicating listening status
Use Case
The net_listening method is useful for:
Node health check
Network status
Error Handling
Status Code
Error Message
Cause
403
Forbidden
Missing or invalid ACCESS-TOKEN
-32600
Invalid Request
Malformed request body
-32602
Invalid params
Invalid method parameters
Web3 Integration
Last updated
Was this helpful?