2

How can I determine for which data account the accountSubscribe web-socket message is for if I'm subscribing to multiple data account at ones. The web-socket message doesn't seem to contain the public key of the data account the message is for.

The accountSubscribe method is documented here.

2 Answers 2

2

When you make a subscription, the RPC responds with an id that uniquely identifies that particular subscription.

{
  "jsonrpc": "2.0",
  "result": 23784,  // <-- Subscription id
  "id": 1,
}

All notifications for that particular subscription will arrive via the websocket connection carrying that id. Use this to correlate the notification to the original subscription.

{
  "jsonrpc": "2.0",
  "method": "accountNotification",
  "params": {
    "result": { /* ... */ },
    "subscription": 23784  // <-- Subscription id
  }
}
0

You can subscribe only to one account per RPC client using accountSubscribe. That's why there is no account key.

1
  • I am able to subscribe to multiple data accounts using the same web-socket connection when using the solana-test-validator. Is this not possible on dev/test and mainnet?
    – Meow
    Jul 31, 2022 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.