title: Can not get concurrent HTTPS requests work with POCO
body: <p>I want to send some https requests to the same endpoint concurrently using Poco (1.6.0), but I am constantly getting exceptions with the code I have done. (However, the same code using HTTP requests works perfectly...)</p>
  
  <p>Here is the code I use:</p>
  
  <pre><code>Poco::Net::initializeSSL();
  
  try {
     Poco::URI ep("https://stackoverflow.com/");
  
     Poco::SharedPtr&lt;Poco::Net::InvalidCertificateHandler&gt; ptrHandler
           = new Poco::Net::AcceptCertificateHandler(false);
     Poco::Net::Context::Ptr context = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE,
                                                     "", "", "", Poco::Net::Context::VERIFY_STRICT,
                                                     9, true, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
     Poco::Net::SSLManager::instance().initializeClient(0, ptrHandler, context);
  
     for (int i = 0; i &lt; 20; ++i)
     {
        // Start an asynchronous HTTPS request
        std::future&lt;bool&gt; f = std::async(std::launch::async, []() -&gt; bool {
                    try {
                       Poco::URI ep("https://github.com/");
                        std::unique_ptr&lt;Poco::Net::HTTPSClientSession&gt; session(
                                 new Poco::Net::HTTPSClientSession (ep.getHost(), ep.getPort()) );
                        Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET,
                                               ep.getPathAndQuery() ,
                                               Poco::Net::HTTPMessage::HTTP_1_1);
                        request.write(std::cerr);
                        try {
                          session-&gt;sendRequest(request);
                        }
                        catch (const Poco::Exception&amp; e) {
                           std::cerr &lt;&lt; "Error A" &lt;&lt; std::endl;
                           std::cerr &lt;&lt; e.code() &lt;&lt; " - " &lt;&lt; e.displayText() &lt;&lt; std::endl;
                           throw;
                        }
  
                        Poco::Net::HTTPResponse response;
                        try {
                          session-&gt;receiveResponse(response);
                        }
                        catch (const Poco::Exception&amp; e) {
                           std::cerr &lt;&lt; "Error B" &lt;&lt; std::endl;
                           std::cerr &lt;&lt; e.code() &lt;&lt; " - " &lt;&lt; e.displayText() &lt;&lt; std::endl;
                           throw;
                        }
                        response.write(std::cerr);
                        std::this_thread::sleep_for(std::chrono::seconds(1));
                       std::cerr &lt;&lt; "Async request ended" &lt;&lt; std::endl;
                    }
                    catch (const Poco::Exception&amp; e) {
                       std::cerr &lt;&lt; "Error :-/" &lt;&lt; std::endl;
                       std::cerr &lt;&lt; e.code() &lt;&lt; " - " &lt;&lt; e.displayText() &lt;&lt; std::endl;
                       throw;
                    }
                    std::cerr &lt;&lt; "Async request ended 2" &lt;&lt; std::endl;
  
                    return true;
        });
  
        // Generate several HTTPS requests until the async request is completed
        std::chrono::microseconds span (10);
        while (f.wait_for(span) != std::future_status::ready)
        {
           std::unique_ptr&lt;Poco::Net::HTTPSClientSession&gt; session(
                    new Poco::Net::HTTPSClientSession (ep.getHost(), ep.getPort()) );
           Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET,
                                   ep.getPathAndQuery() ,
                                   Poco::Net::HTTPMessage::HTTP_1_1);
           request.write(std::cerr);
           try {
              session-&gt;sendRequest(request);
           }
           catch (const Poco::Exception&amp; e) {
  
              std::cerr &lt;&lt; "Error 1" &lt;&lt; std::endl;
              std::cerr &lt;&lt; e.code() &lt;&lt; " - " &lt;&lt; e.displayText() &lt;&lt; std::endl;
              throw;
           }
           Poco::Net::HTTPResponse response;
  
           try {
              session-&gt;receiveResponse(response);
           }
           catch (const Poco::Exception&amp; e) {
              std::cerr &lt;&lt; "Error 2" &lt;&lt; std::endl;
              std::cerr &lt;&lt; e.code() &lt;&lt; " - " &lt;&lt; e.displayText() &lt;&lt; std::endl;
              throw;
           }
           response.write(std::cerr);
        }
        f.get();
     }
  
  }
  catch (const Poco::Exception&amp; e) {
     std::cerr &lt;&lt; "ERROR :-(" &lt;&lt; std::endl;
     std::cerr &lt;&lt; e.code() &lt;&lt; " - " &lt;&lt; e.displayText() &lt;&lt; std::endl;
  }
  
  Poco::Net::uninitializeSSL();
  </code></pre>
  
  <p>This is the issue I got:</p>
  
  <p>When I run the code in QtCreator debugger, I got the following one: Once the async request ends, the current request in the main thread throw a Poco exception.</p>
  
  <pre><code>Error 1
  4 - I/O error: Interrupted
  </code></pre>
  
  <p>However, this seems not to appear outside the QtCreator debugger. This is a bit strange.</p>
  
  <p>This is probably a concurrency issue, but I could not find what I am doing wrong and I didn't see any similar issue on the Internet.
  Could you please help me to find what is my mistake?</p>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT</strong>: Simplified the minimal code and added a few details in the description of the issue.</p>
  
  <p><strong>EDIT2</strong>: It seems I forgot to mention the most important information, the environment under which I get the issue. It is the following: Ubuntu 14.04 LTS 64bit with gcc 4.8.4, gdb 7.7.1, openssl 1.0.1f</p>