nautechsystems/nautilus_trader · error

Connection error: {e}

Error message

Connection error: {e}

What it means

The record channel returned Err(e) — a connection error while streaming from the Databento gateway — before the session had been running for success_threshold. The error is wrapped and propagated so the session restarts.

Source

Thrown at crates/adapters/databento/src/live.rs:773

                },
                result = client.next_record() => result,
            };

            let record = match record_opt {
                Ok(Some(record)) => record,
                Ok(None) => {
                    if session_start.elapsed() >= self.success_threshold {
                        log::debug!("Session ended after successful run");
                        return Ok(true);
                    }
                    anyhow::bail!("Session ended by gateway");
                }
                Err(e) => {
                    if session_start.elapsed() >= self.success_threshold {
                        log::debug!("Connection error after successful run: {e}");
                        return Ok(true);
                    }
                    anyhow::bail!("Connection error: {e}");
                }
            };

            let ts_init = clock.get_time_ns();

            // Decode record
            if let Some(msg) = record.get::<dbn::ErrorMsg>() {
                handle_error_msg(msg);
            } else if let Some(msg) = record.get::<dbn::SystemMsg>() {
                if let Some(ack) = handle_system_msg(msg, ts_init) {
                    self.send_msg(DatabentoMessage::SubscriptionAck(ack));
                }
            } else if let Some(msg) = record.get::<dbn::SymbolMappingMsg>() {
                // Remove instrument ID index as the raw symbol may have changed
                instrument_id_map.remove(&msg.hd.instrument_id);
                instrument_def_price_precision_map.remove(&msg.hd.instrument_id);
                update_price_precision_map_with_symbol_mapping_msg(
                    msg,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Allow the adapter's retry loop to re-establish the session
  2. Increase retry/backoff budget if errors are frequent
  3. Check local network/proxy stability for long-lived streams
  4. Read inner {e} to distinguish auth vs transport issues
Defensive patterns

Strategy: retry

Try / catch

match session.run_session().await {
    Err(e) if e.to_string().contains("Connection error") => {
        warn!("transient connection error: {e}; retrying with backoff");
    }
    other => other?,
}

Prevention

When it happens

Trigger: dbn Live client's next_record returns Err during run_session (transport failure, TLS error, gateway reset) before the success threshold elapsed.

Common situations: Transient network drops, TCP resets, TLS handshake failures mid-stream, Databento gateway restarts.

Related errors


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