TriportRPC

logsUnsubscribe

Cancels an active logsSubscribe stream, identified by the subscription id returned in the subscribe ack.

Solanasol.pubsubbasic+ — per-method tier gating on /ws/sol

logsUnsubscribe stops one log stream that was opened with logsSubscribe on the same WebSocket connection. It takes the integer subscription id from the subscribe ack, returns result: true, and the server stops pushing logsNotification frames for that id. Everything else on the connection — other log filters, account watches, slot ticks — keeps flowing.

Log streams are among the chattiest subscriptions on Solana, especially with the "all" filter or a mentions filter on a busy program, so releasing them promptly matters more here than for most families. Typical moments to call it: an indexer finished its catch-up phase and is switching from the firehose "all" filter to targeted mentions filters; a monitoring dashboard closed the panel that was tailing a program's activity; or you are rotating the set of tracked addresses — since a mentions filter accepts exactly one pubkey and cannot be edited in place, changing what you watch always means subscribing to the new address first, then unsubscribing the old id.

The usual Pub/Sub lifecycle rules apply. Subscription ids are scoped to the current WebSocket session: after a disconnect the server has already discarded every subscription, so replaying stored ids into logsUnsubscribe on a fresh socket fails with -32602 — just resubscribe and track the new ids. A second unsubscribe of the same id fails the same way, because the first call removed it. And notifications already in flight when you send the unsubscribe may still be delivered for a moment; drop frames whose params.subscription you no longer recognise instead of treating them as protocol errors. Closing the socket outright releases all subscriptions at once, so shutdown paths need no explicit unsubscribes.

Parameters

Positional params array: [subscriptionId].

subscriptionIdintegerrequired
Id returned by the logsSubscribe ack on this connection.

Response

Response fields

FieldTypeDescription
resultbooleantrue when the subscription was found and removed.

Errors

CodeMeaningWhen it happens
-32602Invalid paramsThe subscription id does not exist on this connection (already unsubscribed or from a previous session).
4001unauthorizedThe connection was never successfully authenticated.

Notes

  • Swap, then drop: when changing a mentions address, subscribe to the new one before unsubscribing the old to avoid a coverage gap.
  • In-flight frames: a few notifications may still arrive after the ack; filter by known subscription ids.
  • No bulk call needed: closing the WebSocket frees every subscription.
  • Related methods: logsSubscribe.