-
Notifications
You must be signed in to change notification settings - Fork 425
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
boost::exception_detail::clone_impl thrown with 0.13-release #776
Comments
Instances of the client are thread-safe. You can reuse the object in multiple threads without explicit synchronisation. |
Ah, then I was definitely barking up the wrong tree -- thanks for letting me know, I'll come at the problem another way. |
I used to work with a version of cpp-netlib that I compiled around 6 months ago, and I was able to communicate with Google's API without any issues... when I recompiled everything from scratch around a month ago, this problem appeared. I've written some code to consistently reproduce the issue. The following program allows you to make a single http query and outputs the response: // main.cpp
#define BOOST_NETWORK_ENABLE_HTTPS
#include <boost/program_options.hpp>
#include <boost/network/protocol/http.hpp>
#include <string>
#include <utility>
#include <iostream>
int main(int argc, char* argv[]) {
using namespace boost::network;
boost::program_options::variables_map options;
{
using namespace boost::program_options;
options_description options_d("Options");
options_d.add_options()
("headers", value<bool>(), "print headers")
("status", value<bool>(), "print status and message")
("source", value<std::string>(), "source URL")
;
store(parse_command_line(argc, argv, options_d), options);
notify(options);
}
if (options.count("source") < 1) {
std::cout << "Error: Source URL required." << std::endl;
return EXIT_FAILURE;
}
std::string source = options["source"].as<std::string>();
bool show_headers = options.count("headers") ? true : false;
bool show_status = options.count("status") ? true : false;
http::client::request request(source);
http::client::string_type destination_ = host(request);
request << ::boost::network::header("Connection", "close");
http::client::options client_options;
client_options.follow_redirects(true);
http::client client(client_options);
http::client::response response = client.get(request);
if (show_status)
std::cout << status(response) << " " << status_message(response)
<< std::endl;
if (show_headers) {
auto headers_ = response.headers();
for (auto const& header : headers_) {
std::cout << header.first << ": " << header.second << std::endl;
}
std::cout << std::endl;
}
std::cout << body(response);
return EXIT_SUCCESS;
} # Makefile
CPPNETLIB_PATH=/usr/local/lib64
all:
g++ main.cpp \
-lssl \
-lcrypto \
-lboost_program_options \
-lpthread \
-lboost_system \
-lboost_thread \
${CPPNETLIB_PATH}/libcppnetlib-uri.a \
${CPPNETLIB_PATH}/libcppnetlib-client-connections.a Running the program with the following URL will consistently crash, producing this output:
The exception is thrown when calling Note that calling GET https://accounts.google.com/o/oauth2/auth will answer with 400 Bad request. But this isn't what causes the problem: I have verified that even when building a proper query that gets a 200 answer, trying to retrieve the body will throw this exception. |
Any solutions ? I've got the same problem in the latest version. |
Hi -- I'm getting this error thrown:
A quick google of the error turned this stack overflow question up.
At the end of that ticket is this comment:
If I assume that the same approach would work for me, I have the issue that my cpp-netlib client is being created in a fire-and-forget thread each time it is needed. This is because I need them to run concurrently.
Would I need to implement a pool of clients to handle this? Has anyone seen anything similar that they could point me to, if I should?
Thanks for any and all assistance,
Doug.
The text was updated successfully, but these errors were encountered: