Lantern - WebSocket Support

Lantern supports Solana WebSocket methods for real-time account and program subscriptions on a local caching stack.

Supported WebSocket Methods

In addition to answering RPC requests about cached accounts, Lantern supports the following WebSocket methods:

accountSubscribe

Subscribe to account changes

accountUnsubscribe

Unsubscribe from account updates

programSubscribe

Subscribe to program account changes

programUnsubscribe

Unsubscribe from program updates

You can access these methods as usual — just make your requests to the Lantern port in your config file.

WebSockets respond to Lantern's runtime caching feature a little differently than normal RPC calls. See Runtime Behavior for more information.

Usage

Subscribing to an account or program that Lantern is caching will work normally and provide real-time updates as the data changes.

The exact behavior when subscribing to accounts or programs Lantern is not caching depends on the cache_requests setting in your configuration:

cache_requests = true

Subscribing to an uncached account will cause Lantern to fetch and begin caching it. After this, subscriptions work as expected. Note: caching System or Token Program accounts can consume significant bandwidth — a Business plan at FluxRPC is recommended.

Subscribing to an uncached program will fail (returns "not found"). To subscribe to a program, add it to your config file explicitly.

cache_requests = false

Subscribing to an account or program that Lantern is not currently caching will fail (returns "not found").

Regardless of configuration, trying to subscribe to an account or program that doesn't exist will fail (returns "not found").

Open the section overview for the broader context, live navigation, and interactive code examples.

Continue in this section

← Back to documentation home