Skip to content

Making HTTPS call from Daemonize daemon #35

@grantgumina

Description

@grantgumina

I'm using Hyper + Hyper-TLS with the Daemonize crate to make the following HTTPS call from within a Daemon my subprocess runs. Interestingly, if I make a HTTP call things work fine and the request gets POST'ed to my server. However, if I change the BASE_URL to be HTTPS, then I get the following error printed out:

Error {
    kind: Connect,
    cause: Custom {
        kind: Other,
        error: Error {
            code: -909

I can't find any documentation as to what this might be. Also what's disturbing is that after I print this error, no other print statements are executed because the process seems to have died. Any help would be appreciated. Code using hyper/hyper-tls is below.

    let url: hyper::Uri = format!("{}/logs/new", BASE_URL).parse().unwrap();
    let https_connector = HttpsConnector::new(4).unwrap();
    let client = Client::builder().build(https_connector);
    let method = hyper::Method::POST;
    let mut headers = HeaderMap::new();

    let json_payload = json!({
        "jobName": job_name,
        "line": line,
    });

    let mut req = Request::new(Body::from(json_payload.to_string()));

    headers.insert("x-access-token", HeaderValue::from_str(&token).unwrap());
    headers.insert(
        hyper::header::CONTENT_TYPE,
        HeaderValue::from_static("application/json")
    );

    *req.method_mut() = method;
    *req.uri_mut() = url;
    *req.headers_mut() = headers;

    client.request(req).and_then(|res| {
        Ok(res.status())
    }).from_err::<kraken_utils::FetchError>().from_err()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions