t8y2/dbx · error

invalid TDengine HTTP connection string

Error message

invalid TDengine HTTP connection string

What it means

normalize_connection_string parses a user-supplied TDengine connection string and, for http:// URLs, rewrites the scheme to ws:// with Url::set_scheme. set_scheme fails when the new scheme is invalid in context — here because an http URL with a default port or unusual port/scheme state cannot be renamed — so the driver raises 'invalid TDengine HTTP connection string'. This means an http:// DSN could not be converted to its WebSocket equivalent.

Source

Thrown at agents/drivers/tdengine/src/config.rs:102

    let normalized = if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, "jdbc:TAOS-WS://") {
        format!("{}://{value}", if ssl { "wss" } else { "ws" })
    } else if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, "jdbc:TAOS-RS://") {
        format!("{}://{value}", if ssl { "wss" } else { "ws" })
    } else if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, "tdengine://") {
        format!("{}://{value}", if ssl { "wss" } else { "ws" })
    } else if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, "taosws://") {
        format!("{}://{value}", if ssl { "wss" } else { "ws" })
    } else if let Some(value) = strip_prefix_ignore_ascii_case(trimmed, "taoswss://") {
        format!("wss://{value}")
    } else {
        trimmed.to_string()
    };
    let mut url = Url::parse(&normalized).with_context(|| "invalid TDengine connection string")?;
    if !matches!(url.scheme(), "ws" | "wss" | "http" | "https") {
        bail!("TDengine native agent supports only WebSocket connection strings");
    }
    if matches!(url.scheme(), "http") {
        url.set_scheme("ws").map_err(|_| anyhow::anyhow!("invalid TDengine HTTP connection string"))?;
    } else if matches!(url.scheme(), "https") {
        url.set_scheme("wss").map_err(|_| anyhow::anyhow!("invalid TDengine HTTPS connection string"))?;
    }
    remove_control_params(&mut url);
    Ok(url)
}

fn merge_query_params(url: &mut Url, raw: &str) {
    let raw = raw.trim().trim_start_matches('?');
    if raw.is_empty() {
        return;
    }
    let additions = url::form_urlencoded::parse(raw.as_bytes())
        .filter(|(key, _)| !is_control_param(key))
        .map(|(key, value)| (key.into_owned(), value.into_owned()))
        .collect::<Vec<_>>();
    let mut query = url.query_pairs_mut();
    for (key, value) in additions {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Change the connection string scheme from http:// to ws:// yourself before passing it in.
  2. Include an explicit port in the URL (e.g. ws://host:6041/) so scheme rewriting is unambiguous.
  3. Use wss:// instead of https:// if TLS is needed.

Example fix

// before
let dsn = build_dsn(Some("http://localhost:6041"), &params)?;
// after
let dsn = build_dsn(Some("ws://localhost:6041"), &params)?;
Defensive patterns

Strategy: validation

Validate before calling

// Rust
let url = url::Url::parse(conn_str)?;
if url.scheme() == "http" {
    return Err("rewrite http:// to ws:// with an explicit port before passing to build_dsn");
}

Prevention

When it happens

Trigger: Passing an http:// connection string to build_dsn where Url::set_scheme("ws") fails, notably when the URL has no explicit port (set_scheme rejects changing scheme when it would invalidate the default port binding).

Common situations: Users writing 'http://host:6041' or a URL relying on http's default port 80 and expecting transparent WebSocket upgrade; copy-pasted REST-interface URLs from TDengine docs (taosAdapter REST on 6041).

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/5e957f4447e8d5cc. Report an issue: GitHub.