nautechsystems/nautilus_trader · error

RPC block feed selected without an RPC client

Error message

RPC block feed selected without an RPC client

What it means

subscribe_block_feed resolved the configured backend to BlockFeedBackend::Rpc, but the core client has no RPC client configured (rpc_client is None). The RPC block feed cannot run without an HTTP/WS RPC connection, so the call fails fast.

Source

Thrown at crates/adapters/blockchain/src/data/client.rs:1058

        core_client: &mut BlockchainDataClientCore,
        owner: BlockFeedOwner,
    ) -> anyhow::Result<()> {
        let preferred_backend = if core_client.rpc_client.is_some() {
            BlockFeedBackend::Rpc
        } else {
            BlockFeedBackend::HyperSync
        };
        let Some(backend) = core_client
            .subscription_manager
            .add_block_demand(owner, preferred_backend)
        else {
            return Ok(());
        };

        let started_backend = match backend {
            BlockFeedBackend::Rpc => {
                let Some(rpc) = core_client.rpc_client.as_mut() else {
                    anyhow::bail!("RPC block feed selected without an RPC client")
                };

                match rpc.subscribe_blocks().await {
                    Ok(()) => {
                        log::debug!("Successfully subscribed to blocks via RPC");
                        BlockFeedBackend::Rpc
                    }
                    Err(e) if owner == BlockFeedOwner::Explicit => {
                        log::warn!(
                            "RPC blocks subscription failed: {e}, falling back to HyperSync"
                        );
                        core_client.hypersync_client.subscribe_blocks();
                        tokio::task::yield_now().await;
                        BlockFeedBackend::HyperSync
                    }
                    Err(e) => return Err(e.into()),
                }
            }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Provide an RPC (WS) URL in the blockchain adapter config so rpc_client is initialized
  2. Or select the HyperSync block feed backend instead
  3. Check that rpc_client construction did not silently fail during client build

Example fix

// before
# config: block_feed_backend = "rpc"  (no rpc_url set)
// after
[rpc]
url = "wss://base-mainnet.g.alchemy.com/v2/<key>"
block_feed_backend = "rpc"
Defensive patterns

Strategy: validation

Validate before calling

if backend == BlockFeedBackend::Rpc && client.rpc_client().is_none() {
    return Err(anyhow::anyhow!("configure an RPC URL before selecting the rpc block feed"));
}

Try / catch

match client.subscribe_block_feed().await {
    Err(e) if e.to_string().contains("without an RPC client") => {
        log::error!("RPC URL not configured; enable rpc or use hypersync backend");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling subscribe_block_feed (or triggering block feed subscription via handle_subscribe_command) when block-feed backend is configured to Rpc but rpc_client was never constructed — e.g. missing RPC URL in config, or the client was built in HyperSync-only mode.

Common situations: Config omits the RPC endpoint/WS URL; environment variable for RPC URL unset; user intended HyperSync backend but selected Rpc; RPC client failed to initialize earlier and was left as None.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/26ff1dc82cd24d50. Report an issue: GitHub.