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

Slow performance on Windows 10 #31

Open
davechurchill opened this issue Mar 1, 2021 · 1 comment
Open

Slow performance on Windows 10 #31

davechurchill opened this issue Mar 1, 2021 · 1 comment

Comments

@davechurchill
Copy link

I can install and compile your code very easily, but for some reason a simple GET to a localhost server takes upwards of 20 seconds, whereas it is instant in firefox. Is there a Windows firewall setting or something that may be causing this?

@shyney7
Copy link

shyney7 commented Oct 11, 2021

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants