signatureUnsubscribe
Unsubscribe from signature confirmation notification
Common use cases
| Cancel monitoring before confirmation | Unsubscribe when abandoning transaction monitoring before notification arrives, such as user-initiated cancellation or application timeout. Frees server resources and prevents orphaned subscriptions. |
| Clean up on application shutdown | Call signatureUnsubscribe in cleanup handlers when closing WebSocket connection or unmounting components. Ensures proper resource cleanup even though signatureSubscribe auto-cancels after notification. |
Parameters
subscriptionId (number, required)
subscription id to cancel
Request
- wscat
- JavaScript
- Python
wscat -c wss://solana-mainnet.api.syndica.io -x '{
"jsonrpc": "2.0",
"id": 1,
"method": "signatureUnsubscribe",
"params": [
0
]
}'
const ws = new WebSocket('wss://solana-mainnet.api.syndica.io');
ws.on('open', function open() {
ws.send(JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "signatureUnsubscribe",
"params": [
0
]
}));
});
ws.on('message', function incoming(data) {
console.log(data);
});
import websocket
import json
ws = websocket.create_connection('wss://solana-mainnet.api.syndica.io')
ws.send(json.dumps({
"jsonrpc": "2.0",
"id": 1,
"method": "signatureUnsubscribe",
"params": [
0
]
}))
result = ws.recv()
print(result)
ws.close()
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
Do I need to call signatureUnsubscribe after receiving a notification?
No. signatureSubscribe automatically cancels after sending signatureNotification. Explicit unsubscribe only needed if cancelling before notification arrives.
What happens if I call signatureUnsubscribe with an invalid subscription ID?
Returns JSON-RPC error -32602 with message "Invalid subscription id." Subscription ID may be invalid if already auto-cancelled after notification or never existed.
Should I unsubscribe on WebSocket disconnect?
Not necessary - server automatically cleans up all subscriptions when WebSocket connection closes. Explicit unsubscribe only needed for graceful cleanup before disconnect.
Related Methods
signatureSubscribe
Creates signature subscription that signatureUnsubscribe cancels. Auto-expires after notification, so explicit unsubscribe rarely needed. Every signatureSubscribe can have optional signatureUnsubscribe for early cancellation.
accountUnsubscribe
Cancels accountSubscribe subscriptions. Unlike signatureSubscribe which auto-cancels, accountSubscribe requires explicit unsubscribe for cleanup. Similar error handling: invalid ID returns -32602.
slotUnsubscribe
Cancels slotSubscribe subscriptions. Follows identical unsubscribe pattern: single subscription ID parameter, returns boolean. More commonly used than signatureUnsubscribe since slot subscriptions don't auto-expire.
getSignatureStatuses
HTTP alternative for checking transaction status. Use instead of signatureSubscribe/signatureUnsubscribe cycle when only single status check needed, avoiding WebSocket subscription overhead.
External Resources
- Solana Official Documentation
- Solana Official Documentation: WebSocket Methods - Complete WebSocket API reference including subscription lifecycle, unsubscribe patterns, and error handling for all subscription methods.