eth_unsubscribe - Tempo

Example code for the eth_unsubscribe JSON-RPC method. Complete guide on how to use eth_unsubscribe JSON-RPC in GetBlock Web3 documentation.

Cancels an existing subscription created with eth_subscribe. Like eth_subscribe, only available over WebSocket transport.

WebSocket-only method. Available only over the WebSocket transport at wss://go.getblock.io/<ACCESS-TOKEN>/. Calling it over HTTP POST returns an Invalid Request error.

Parameters

Parameter
Type
Required
Description

subscriptionId

string

Yes

The subscription ID returned by eth_subscribe

Request Example

# WebSocket-only method. Use wscat (or similar) to connect first:
wscat -c 'wss://go.getblock.io/<ACCESS-TOKEN>/'

# Then send:
{"jsonrpc": "2.0", "method": "eth_unsubscribe", "params": ["0x9cef478923ff08bf67fde6c64013158d"], "id": "getblock.io"}

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": true
}

Response Parameters

Field
Type
Description

result

boolean

true if the subscription was cancelled, false if it did not exist

Use Cases

  • Stopping a live feed when the user navigates away

  • Reconnecting subscribers after a connection drop

  • Cleanup in WebSocket-based microservices

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

-32600

Invalid Request

eth_unsubscribe was called over HTTP; use a WebSocket connection instead

SDK Integration

Last updated

Was this helpful?