76 lines
3.1 KiB
Bash
76 lines
3.1 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Diagnose raw HTTP response from public RPC endpoints (to debug E2E failures).
|
||
|
|
# Usage: ./scripts/diagnose-rpc-response.sh
|
||
|
|
# Run from a host that can reach 76.53.10.36 (same as E2E).
|
||
|
|
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
# Load IP configuration
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||
|
|
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
|
||
|
|
|
||
|
|
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
CYAN='\033[0;36m'
|
||
|
|
YELLOW='\033[1;33m'
|
||
|
|
GREEN='\033[0;32m'
|
||
|
|
RED='\033[0;31m'
|
||
|
|
NC='\033[0m'
|
||
|
|
|
||
|
|
log_section() { echo -e "\n${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n${CYAN}$1${NC}\n${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}\n"; }
|
||
|
|
|
||
|
|
RPC_TIMEOUT=${RPC_TIMEOUT:-15}
|
||
|
|
BODY_MAX=600
|
||
|
|
|
||
|
|
urls=(
|
||
|
|
"https://rpc-http-pub.d-bis.org"
|
||
|
|
"https://rpc.d-bis.org"
|
||
|
|
"https://rpc.public-0138.defi-oracle.io"
|
||
|
|
"https://rpc.defi-oracle.io"
|
||
|
|
)
|
||
|
|
|
||
|
|
log_section "RPC response diagnostic (eth_blockNumber)"
|
||
|
|
echo "Timeout: ${RPC_TIMEOUT}s. Showing HTTP code and first ${BODY_MAX} chars of body."
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
for url in "${urls[@]}"; do
|
||
|
|
echo -e "${CYAN}--- $url ---${NC}"
|
||
|
|
out=$(curl -s -w "\n%{http_code}" -m "$RPC_TIMEOUT" -X POST "$url" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' 2>/dev/null) || true
|
||
|
|
body=$(echo "$out" | head -n -1)
|
||
|
|
code=$(echo "$out" | tail -n 1)
|
||
|
|
if [ -z "$code" ]; then
|
||
|
|
code="(timeout or no response)"
|
||
|
|
fi
|
||
|
|
echo "HTTP code: $code"
|
||
|
|
if [ -n "$body" ]; then
|
||
|
|
echo "Body (first ${BODY_MAX} chars):"
|
||
|
|
echo "$body" | head -c "$BODY_MAX"
|
||
|
|
echo ""
|
||
|
|
if echo "$body" | jq -e '.result' >/dev/null 2>&1; then
|
||
|
|
echo -e "${GREEN}[✓] Valid JSON with .result${NC}"
|
||
|
|
else
|
||
|
|
echo -e "${YELLOW}[?] No .result or invalid JSON (may be HTML/502)${NC}"
|
||
|
|
fi
|
||
|
|
else
|
||
|
|
echo -e "${RED}(empty body)${NC}"
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
done
|
||
|
|
|
||
|
|
log_section "Direct backend (LAN only)"
|
||
|
|
echo "If this host can reach ${RPC_PUBLIC_1:-${RPC_PUBLIC_1:-192.168.11.221}} (Besu RPC), testing direct eth_blockNumber:"
|
||
|
|
direct=$(curl -s -m 5 -X POST "http://${RPC_PUBLIC_1}:8545" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' 2>/dev/null) || direct="(unreachable or timeout)"
|
||
|
|
if echo "$direct" | jq -e '.result' >/dev/null 2>&1; then
|
||
|
|
echo -e "${GREEN}${RPC_PUBLIC_1:-${RPC_PUBLIC_1:-192.168.11.221}}:8545 — OK: $direct${NC}"
|
||
|
|
else
|
||
|
|
echo "${RPC_PUBLIC_1:-${RPC_PUBLIC_1:-192.168.11.221}}:8545 — $direct"
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
echo "If public URLs fail but ${RPC_PUBLIC_1:-${RPC_PUBLIC_1:-192.168.11.221}} works: NPMplus proxy hosts (rpc-http-pub.d-bis.org → ${RPC_PUBLIC_1:-${RPC_PUBLIC_1:-192.168.11.221}}:8545) may be wrong or NPMplus cannot reach ${RPC_PUBLIC_1:-${RPC_PUBLIC_1:-192.168.11.221}}."
|
||
|
|
echo "If both fail: Besu (VMID 2201) may be down or not listening on 8545."
|