GithubHelp home page GithubHelp logo

Comments (1)

shyney7 avatar shyney7 commented on July 17, 2024

@elnormous
Im also having a really slow binary execution.
I'm using it to send data to influxdb 2 REST API. The data arrival with this library works just fine and appears in influxdb immediately. But the program keeps stuck and doesnt print any response after ~ 20-30 seconds. I think its the buffering of the response? Is there any way to skip response buffering?

Here is the code that I use:

#include "include/HTTPRequest.hpp"
#include <iostream>
#include <chrono>
#include <string>


int main() {
    try {
        http::Request request{"http://ip.to.influxdb.server:8086/api/v2/write?org=roboflex&bucket=roboflex-test1&precision=ns"};

        float pseudo_measurement = 49.77;
        long long t = std::chrono::time_point_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now()).time_since_epoch().count();

        std::string lineprotocol = "testmeasurement,pseudotag=pseudo1 test_percent=";
        lineprotocol += std::to_string(pseudo_measurement);
        lineprotocol += " ";
        lineprotocol += std::to_string(t);

        const auto response = request.send("POST", lineprotocol, {
            "Authorization: Token MyInfluxdbToken",
            "Content-Type: text/plain; charset=utf-8",
            "Accept: application/json"
        });
        std::cout << std::string{response.body.begin(), response.body.end()} << '\n';
    }
    catch (const std::exception& e) {
        std::cerr << "Request failed, error: " << e.what() << '\n';
    }
    

    return EXIT_SUCCESS;
}

Here is the time it took for execution:
grafik

EDIT:
If I pass a delay to the send method with chrono the execution of the binary is fast and the data arrives just fine although there is an error that is thrown:
Request failed, error: Request timed out

from httprequest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.