TriportRPC

programUnsubscribe

Last updated:

programUnsubscribe removes one program-account stream that was opened with programSubscribe on the same WebSocket connection. Send the integer subscription id from the subscribe ack; the server replies result: true and stops delivering programNotification frames for that id. The socket stays open and every other subscription on it continues untouched.

The most common reason to call it is filter rotation. A program subscription's filters are fixed the moment it is created — there is no way to add a memcmp needle or tighten a dataSize on a live stream. The working pattern is make-before-break: open a new subscription with the updated filters, wait for its ack, then unsubscribe the old id. Done in that order there is no window where matching account changes can slip past both streams (you may briefly receive duplicates instead — de-duplicate by pubkey + slot). Other natural moments: an indexer that bootstrapped from a getProgramAccounts snapshot and has caught up no longer needs its wide catch-all stream; a liquidation bot unwinds coverage of a market it exited; a dashboard tab watching a pool closes.

The lifecycle rules are the standard Pub/Sub ones. Ids are private to the current WebSocket session — after a reconnect the server has already dropped every subscription, so an unsubscribe with a stale id fails with -32602 (invalid subscription id), as does a second unsubscribe of the same id. Notifications already queued when the unsubscribe lands may still be delivered for a brief moment; ignore frames whose params.subscription is no longer in your routing table. And if you are shutting the whole connection down, just close the socket — that releases all subscriptions server-side in one step.

Parameters

This method takes no parameters.

Returns

programUnsubscribe return value
FieldType
resultobject

Examples

curl https://triport.io/sol \
  -X POST -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <api-key>' \
  -d '{"id":1,"method":"programUnsubscribe","params":[],"jsonrpc":"2.0"}'
const res = await fetch("https://triport.io/sol", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
  body: JSON.stringify({
  "id": 1,
  "method": "programUnsubscribe",
  "params": [],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post(
    "https://triport.io/sol",
    headers={"Authorization": "Bearer <api-key>"},
    json={"id":1,"method":"programUnsubscribe","params":[],"jsonrpc":"2.0"},
)
print(resp.json())

Usage

  1. Transport: WebSocket.
  2. Networks: mainnet, devnet, testnet.
  3. Credit cost: 1 per call.

FAQ

What does programUnsubscribe do?
Cancels an active programSubscribe stream, identified by the subscription id returned in the subscribe ack.
How many credits does programUnsubscribe cost?
programUnsubscribe costs 1 credit(s) per call on Triport by default.
Is programUnsubscribe available over WebSocket?
Yes, programUnsubscribe supports WebSocket.