t8y2/dbx · error

invalid TDengine HTTPS connection string

Error message

invalid TDengine HTTPS connection string

What it means

The https:// counterpart of the HTTP variant: normalize_connection_string rewrites https schemes to wss via Url::set_scheme, and if that mutator fails it raises 'invalid TDengine HTTPS connection string'. set_scheme can fail when the URL's port/default-port state is incompatible with the new scheme, so an https DSN could not be converted to a WebSocket-secure DSN.

Source

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

    } 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 {
        query.append_pair(&key, &value);
    }

View on GitHub (pinned to c0390bff16)

Solutions

  1. Specify the scheme as wss:// directly in the connection string.
  2. Add an explicit port to the URL to avoid scheme-rewrite port conflicts.
  3. Confirm the endpoint actually serves the TDengine WebSocket protocol on that port.

Example fix

// before
let dsn = build_dsn(Some("https://db.example.com"), &params)?;
// after
let dsn = build_dsn(Some("wss://db.example.com:6041"), &params)?;
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Passing an https:// connection string to build_dsn where Url::set_scheme("wss") fails, e.g. a URL bound to http default port semantics or missing an explicit port.

Common situations: Users reusing TLS REST endpoint URLs (https://host:6041/rest/...) for the WebSocket agent, or URLs behind proxies that omit the port.

Related errors


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