mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
tools: add http json-rpc reachability check
Adds check_http_rpc.sh, a small script that sends a web3_clientVersion request to confirm HTTP RPC reachability.
This commit is contained in:
parent
6978ab48aa
commit
889dc67021
1 changed files with 27 additions and 0 deletions
27
scripts/check_http_rpc.sh
Normal file
27
scripts/check_http_rpc.sh
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Simple helper to verify that an HTTP JSON-RPC endpoint is reachable.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/check_http_rpc.sh
|
||||
# RPC_URL=http://10.0.0.5:8545 ./scripts/check_http_rpc.sh
|
||||
|
||||
RPC_URL="${RPC_URL:-http://127.0.0.1:8545}"
|
||||
|
||||
echo "Checking HTTP JSON-RPC endpoint: ${RPC_URL}"
|
||||
echo
|
||||
|
||||
payload='{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}'
|
||||
|
||||
response="$(curl -s -X POST "${RPC_URL}" -H "Content-Type: application/json" -d "${payload}")"
|
||||
|
||||
if [ -z "${response}" ]; then
|
||||
echo "No response received. Is the node running and HTTP enabled?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Raw response:"
|
||||
echo "${response}"
|
||||
echo
|
||||
echo "If this includes a valid client version string, the HTTP JSON-RPC endpoint is working."
|
||||
Loading…
Reference in a new issue