Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "connection error: builder error: failed to parse header value" from Query() #131

Open
capveg-netdebug opened this issue Dec 14, 2023 · 0 comments

Comments

@capveg-netdebug
Copy link

Nothing matching this error in the issues that I've seen.

  • Rust Version:
    stable-x86_64-unknown-linux-gnu (default)
    rustc 1.74.0 (79e9716c9 2023-11-13)
  • Runtime version (e.g. Tokio):
    tokio = { version = "1.29.1", features = ["full"] }
  • OS Version:
    Ubuntu 22.04
    Steps to Reproduce:

Very basic hello world but using .with_token(). Any idea what this could be? This is presumably coming from influxdb/src/client/mod.rs:264 but it's really unclear what to look at next or even where the error is coming from.

Any help would be appreciated! Thank you in advance.

use log::warn;

#[derive(InfluxDbWriteable)]
struct TimeSeriesDesktopCounter {
    time: DateTime<Utc>,
    source: String,
    counter: String,
    value: u64,
}

#[tokio::main]
fn main() {
    const TIMESERIESDB_URL: &str = "https://XXXXX.cloudhosted-by-influx.cloud2.influxdata.com";
    const API_TOKEN_FILE: &str = ".influxdb_api_token";
    const TIMESERIESDB_NAME: &str = "desktop-counters";
    let client = Client::new(TIMESERIESDB_URL, TIMESERIESDB_NAME);
    let token = std::fs::read_to_string(".influx_api_token).unwrap_or_else(|e| {
        panic!("Critical auth token {} missing:: {}", ".influx_api_token, e)
    });
    let client = client.with_token(token);    
    let queries = &[("foo", 1), ("bar", 2), ("baz", 3)]
        .iter()
        .map(|(c, v)| {
            TimeSeriesDesktopCounter {
                time: Utc::now(),
                source: "test".to_string(), 
                counter: c.to_string(),
                value: *v,
            }
            .into_query("test_measurement")
        })
        .collect::<Vec<influxdb::WriteQuery>>();
        match client.query(queries).await {
               Ok(out) => warn!("Returned Ok()  but got string  {}", out),
              Err(e) => warn!("Error writing to client: {}", e),
    }

}

Produces:

running 1 test
Client = Client { url: "https://XXX.influxdata.com", parameters: {"db": "desktop-counters"}, .. }
Error writing to client: connection error: builder error: failed to parse header value
test desktop_websocket::test::test_cloud_timeseries_db_store ... ok```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants