Documentation Index
Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
Use this file to discover all available pages before exploring further.
此方法不接受任何参数。
以下状态值之一:
"ok":节点健康且已同步到最新
"behind":节点落后若干 slot
"unknown":无法确定节点健康状态
代码示例
基本请求
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getHealth"
}'
替代 HTTP GET 请求
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY/health
使用 web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
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);
}
注意事项
- 此方法通常用于负载均衡器健康检查
- HTTP GET 端点
/health 提供相同的信息
- 如果节点落后于最新集群 slot 超过
HEALTH_CHECK_SLOT_DISTANCE 个 slot,则被视为 “behind”
- “unknown” 状态通常表示节点正在启动或遇到问题
最佳实践
- 使用此端点进行基本健康监控
- 基于健康状态实现熔断器
- 考虑使用更详细的方法获取特定健康指标:
getVersion 获取软件版本
getSlot 获取 slot 进度
getBlockHeight 获取区块高度
- 为健康检查设置适当的超时
- 处理所有可能的响应值
常见错误
| 错误码 | 消息 | 解决方案 |
|---|
| -32601 | Method not found | 验证是否连接到 Solana RPC 节点 |
| -32603 | Internal error | 节点可能遇到问题 |
| 503 | Service Unavailable | 节点尚未准备好处理请求 |
-
负载均衡器配置
location /health {
proxy_pass http://backend;
proxy_next_upstream error timeout http_503;
}
-
健康监控
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);
}
}
-
客户端负载均衡
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');
}
-
系统状态仪表板
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);
}