1

I'm doing some Web3 stuff, when an error appeared at the beginning of the process. Targeting the problem, I realized that the problem was with my RPC (which may have crashed). I temporarily tried an RPC from Solana's doc, (Serum) and same, same problem. I then switched to the mainnet-beta RPC and there it worked. I specify that I did not exceed the rate-limit. So I wondered if there was a way to test an RPC, in case of error go to a backup?

1 Answer 1

2

You can test the current health of a node using the getHealth RPC method defined in the documentation.

For example a request would look like:

curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
  {"jsonrpc":"2.0","id":1, "method":"getHealth"}
'

Healthy Response:

{ "jsonrpc": "2.0", "result": "ok", "id": 1 }

Unhealthy Response:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32005,
    "message": "Node is unhealthy",
    "data": {}
  },
  "id": 1
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.