Parameters

This method does not take any parameters.

Response

result
string

One of the following status values:

  • "ok": Node is healthy and up-to-date
  • "behind": Node is behind by some number of slots
  • "unknown": Node health cannot be determined

Code Examples

Basic Request

curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getHealth"
}'

Alternative HTTP GET Request

curl https://rpc.orbitflare.com/health

Using web3.js

import { Connection } from '@solana/web3.js';

const connection = new Connection('https://rpc.orbitflare.com');

const health = await connection.getHealth();
console.log('Node health:', health);

// Example: Check if node is healthy
const isHealthy = health === 'ok';
if (!isHealthy) {
  console.warn('Node is not healthy:', health);
}

Notes

  1. This method is commonly used for load balancer health checks
  2. The HTTP GET endpoint /health provides the same information
  3. A node is considered “behind” if it’s more than HEALTH_CHECK_SLOT_DISTANCE slots from the latest cluster slot
  4. The “unknown” status typically indicates the node is bootstrapping or having issues

Best Practices

  1. Use this endpoint for basic health monitoring
  2. Implement circuit breakers based on health status
  3. Consider using more detailed methods for specific health metrics:
    • getVersion for software version
    • getSlot for slot progress
    • getBlockHeight for block height
  4. Set appropriate timeouts for health checks
  5. Handle all possible response values

Common Errors

CodeMessageSolution
-32601Method not foundVerify you’re connected to a Solana RPC node
-32603Internal errorNode may be experiencing issues
503Service UnavailableNode is not ready to handle requests

Use Cases

  1. Load Balancer Configuration

    location /health {
      proxy_pass http://backend;
      proxy_next_upstream error timeout http_503;
    }
    
  2. Health Monitoring

    async function monitorHealth(endpoint: string) {
      const connection = new Connection(endpoint);
      try {
        const health = await connection.getHealth();
        if (health !== 'ok') {
          alertNodeUnhealthy(endpoint, health);
        }
      } catch (error) {
        alertNodeError(endpoint, error);
      }
    }
    
  3. Client-Side Load Balancing

    async function getHealthyEndpoint(endpoints: string[]) {
      for (const endpoint of endpoints) {
        const connection = new Connection(endpoint);
        try {
          const health = await connection.getHealth();
          if (health === 'ok') {
            return endpoint;
          }
        } catch (error) {
          continue;
        }
      }
      throw new Error('No healthy endpoints available');
    }
    
  4. System Status Dashboard

    interface NodeStatus {
      endpoint: string;
      health: string;
      lastChecked: Date;
    }
    
    async function updateDashboard(nodes: NodeStatus[]) {
      for (const node of nodes) {
        const connection = new Connection(node.endpoint);
        try {
          node.health = await connection.getHealth();
        } catch (error) {
          node.health = 'error';
        }
        node.lastChecked = new Date();
      }
      renderDashboard(nodes);
    }