#!/usr/bin/env bash # WebSocket connectivity verification for RPC endpoints # Requires: curl (for HTTP upgrade) or wscat/websocat if installed set -euo pipefail WS_URL="${1:-wss://wss.defi-oracle.io}" TIMEOUT="${2:-5}" echo "Testing WebSocket: $WS_URL (timeout ${TIMEOUT}s)" if command -v websocat &>/dev/null; then echo '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' | timeout "$TIMEOUT" websocat -t "$WS_URL" -n1 2>/dev/null && echo "OK" || echo "FAIL" elif command -v wscat &>/dev/null; then timeout "$TIMEOUT" wscat -c "$WS_URL" -x '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' 2>/dev/null && echo "OK" || echo "FAIL" else echo "Install websocat or wscat for WebSocket testing: apt install websocat" echo "Fallback: node scripts/verify-ws-rpc-chain138.mjs" exit 1 fi