Skip to main content

rootUnsubscribe

Unsubscribe from root notifications

Common use cases
Cleanup on application shutdownCancel root subscription when closing connection or shutting down monitoring service. Essential for preventing resource leaks and ensuring clean WebSocket closure; always call before disconnecting.
Switch monitoring targetsUnsubscribe from one validator's root updates before subscribing to another. Prevents accumulating unnecessary subscriptions when switching between validators or RPC endpoints.

Parameters

subscriptionId (number, required)

subscription id to cancel

Request

wscat -c wss://solana-mainnet.api.syndica.io -x '{
"jsonrpc": "2.0",
"id": 1,
"method": "rootUnsubscribe",
"params": [
0
]
}'
Network Selection

Replace mainnet with devnet in the URL to query devnet instead.

Response

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

Response Fields

Return value: boolean

unsubscribe success message

FAQ and Troubleshooting

What happens if I don't call rootUnsubscribe?

The subscription persists until WebSocket disconnection, consuming server resources and potentially causing memory leaks in long-running applications. Always unsubscribe when done.

Can I reuse a subscription ID after unsubscribing?

No. Each subscription ID is unique per WebSocket connection. Create a new subscription with rootSubscribe if you need to resume monitoring.

What does the boolean result mean?

true indicates successful unsubscription, false means the subscription ID wasn't found (already unsubscribed or never existed).

rootSubscribe
Creates root subscription. Always paired with rootUnsubscribe; every rootSubscribe should have corresponding rootUnsubscribe call for proper resource management.

slotUnsubscribe
Cancels slot subscription. Similar unsubscribe pattern; both follow standard WebSocket subscription lifecycle where unsubscribe methods take subscription ID and return boolean.

External Resources