Skip to main content

blockUnsubscribe

Unsubscribe from block notifications

Common use cases
Graceful subscription cleanupProperly unsubscribe from blockSubscribe when your application shuts down or no longer needs block updates, freeing server resources and preventing connection leaks.
Dynamic subscription managementStop and restart block subscriptions based on application state (e.g., user navigation, focus changes) to conserve bandwidth and processing resources.

Parameters

subscriptionId (integer, required)

subscription id to cancel

Request

wscat -c wss://solana-mainnet.api.syndica.io -x '{
"jsonrpc": "2.0",
"id": 1,
"method": "blockUnsubscribe",
"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

When should I call blockUnsubscribe?

Always unsubscribe when you stop needing block updates—on application shutdown, component unmount, or when switching data sources. This prevents resource leaks on both client and server.

What is the subscription ID?

The numeric ID returned by blockSubscribe when you initially subscribed. Store this value to unsubscribe later.

What happens if I don't unsubscribe?

The server continues sending block notifications, wasting bandwidth and server resources. Most providers will eventually timeout idle connections, but explicit cleanup is best practice.

Can I unsubscribe from a closed connection?

No. If the websocket connection is already closed, the subscription is implicitly canceled. Only call blockUnsubscribe on active connections.

blockSubscribe
Creates the block subscription that this method cancels. You must call blockSubscribe first to receive the subscription ID needed for unsubscribing.

logsUnsubscribe
Unsubscribe pattern for transaction logs. Same concept—use subscription ID to cancel active subscription.

accountUnsubscribe
Unsubscribe pattern for account updates. All websocket unsubscribe methods follow the same subscription ID pattern.

External Resources