Connection establishment
Use a standard WebSocket client:Heartbeats
Most WebSocket libraries, including browsers, automatically answer control-frame pings. You do not need to send JSON-RPC messages to keep the connection alive. Browser JavaScript does not expose ping/pong control frames.
A pong resets the missed-heartbeat count. If a client never answers, the nominal timeline is:
Idle timeout and session duration
The WebSocket transport has a two-hour idle timeout. It is not a maximum session lifetime: responsive connections can remain open beyond two hours. Traffic, including heartbeat replies, prevents an idle connection from reaching that timeout. Reconnect whenever the connection closes. Do not rely on a periodic two-hour disconnect or a particular idle-timeout close message.Connection closure
These application-level closure cases have explicit meanings:
A JSON-RPC rate-limit error can be returned on an open connection. It does not inherently mean the socket closes with code 1008. Deployments, access changes, proxies, and network failures can produce other close events; handle closure regardless of code.
The released Core socket does not promise a dedicated slow-client close code.
Bound your own processing and subscription volume, reconnect with capped
backoff, and reconcile missed events after any closure.
Reconnection
Reconnect with capped exponential backoff and jitter, then recreate the subscriptions your application still needs. Subscription IDs belong to the old connection and must be replaced with the new IDs returned byeth_subscribe.
This Node.js example uses the ws package and subscribes to new heads after each connection:
Subscription cleanup
When your socket closes, Lasso detaches its logical subscriptions and releases their resources. Shared upstream streams can remain open for other clients or internal monitoring; disconnecting one client must not interrupt them. Useeth_unsubscribe when you no longer need an individual subscription. Closing the socket also cleans up its subscriptions; you do not need to wait for asynchronous unsubscribe calls during page unload.
Operating guidance
- Let your WebSocket library answer pings promptly; avoid blocking its event loop.
- Treat a long gap in notifications separately from a failed connection. A healthy stream may have no matching events.
- Track reconnect frequency, subscription errors, and the last processed block.
- Expect reconnects during deployments and network changes.
- If a profile or provider configuration changes, inspect the active routes before repeatedly retrying.