0

I have the below code executing in a loop which has exception handling.

 using namespace boost::network;
            http::client client;
            http::client::request request("https://testserver.com/");
            request << header("Connection", "close");
            http::client::response response = client.get(request);
            std::string strOutput = body(response);

The code runs fine however if I disable my network interface to test my software in case of network failure I receive this error,

terminate called after throwing an instance of 'boost::exception_detail::clone_impl >' what(): boost thread: trying joining itself: Resource deadlock avoided

I can't seem to catch this error. This code performs a status check 24/7 so it most likely will find a time when there is a network error. The worst part is that it may fail after 1, 2, 3, or on the 4th try. I would really like to avoid implementing the HTTP protocol socket myself with sockets but I may need to. Any ideas?

4
  • are you sure that this is the exact error message? It seems angle brackets are not balanced. Commented Jan 9, 2014 at 0:27
  • The error doesn't seem to be related with the code above. How are the ioservice and the ioservice threads created? I haven't used http but I'm assuming it's based on boost::asio.. Commented Jan 9, 2014 at 4:18
  • The author of library found the solution to be using the same instance of the client and not creating/destroying it each time. Commented Jan 10, 2014 at 19:31
  • github.com/cpp-netlib/cpp-netlib/issues/358 Commented Jan 11, 2014 at 7:35

1 Answer 1

0

The author of library found the solution to be using the same instance of the client and not creating/destroying it each time

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.