Comments (1)
@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:
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)
- send Variable GET Request
- Json post bug
- Errors when including HOT 3
- Numerous "unresolved external symbol" Errors when running HOT 3
- basic_string::_M_create HOT 2
- Empty output HOT 1
- Authentication error
- Using https HOT 2
- An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was ful
- Cant download a file?
- What is the reason for handling interrupted system calls (EINTR) throughout the code?
- A 204 response results in timeouts if connection is kept-alive...
- Failed when compile with MSVC HOT 1
- Inconsistent use of 'uri' and 'url' in example/main.cpp
- Errors when including single-header file
- Post requests don't work. HOT 1
- Using header in request for authentification HOT 1
- A couple of ideas HOT 2
- A fix for receive response
- A lightweight library with HTTPS support has arrived.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httprequest.