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?

user246181
  • 17
  • 1
  • 8
  • are you sure that this is the exact error message? It seems angle brackets are not balanced. – Yousf Jan 09 '14 at 00: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`.. – ichramm Jan 09 '14 at 04:18
  • The author of library found the solution to be using the same instance of the client and not creating/destroying it each time. – user246181 Jan 10 '14 at 19:31
  • https://github.com/cpp-netlib/cpp-netlib/issues/358 –  Jan 11 '14 at 07:35

1 Answers1

0

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

user246181
  • 17
  • 1
  • 8