BNB Smart Chain

BNB Smart Chain

eth_unsubscribe

On BNB Smart Chain, the BNB-settled network with three-second blocks, streaming clients open live feeds through eth_subscribe over a WebSocket connection. eth_unsubscribe closes one of those feeds. Give it the subscription ID that eth_subscribe previously returned and the node stops pushing notifications for it, whether that feed was a newHeads stream of incoming blocks or a logs stream of BEP-20 events. The method is WebSocket-only and means nothing over plain HTTP. Open the socket at https://bsc.therpc.io/YOUR_API_KEY on chain ID 56, and the call replies with a boolean telling you whether the subscription existed and was cancelled.

Use cases

  • Halt a newHeads block feed the instant a user leaves a live BSC explorer view, so the socket stops delivering updates nobody is watching.
  • Rotate a logs subscription by cancelling the stale ID first, then opening a fresh one with revised address or topic filters.

Parameters

#NameTypeRequiredDescription
1subscriptionIdstringYesThe hex subscription ID returned by eth_subscribe.

Response

TypeDescription
boolean`true` if the subscription was found and cancelled. `false` if it did not exist.

Example request

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_unsubscribe",
"params": ["0x1"],
"id": 1
}'

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32602invalid subscription idThe subscription ID is malformed or belongs to a different connection.
-32000subscription not foundThe subscription was already cancelled or never existed.

Common pitfalls

  • The cancellation must travel over the exact same WebSocket connection that opened the subscription; an ID issued on one socket is invalid on any other.
  • Dropping the WebSocket connection altogether discards every subscription tied to it, so an explicit unsubscribe is optional in that case — though calling it deliberately keeps long-lived sockets tidy.

Supported networks

  • Mainnet — Chain ID: 56
  • Testnet — Chain ID: 97

See also

Parameters

The hex subscription ID returned by eth_subscribe.

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_unsubscribe","params":[""]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.