title: cpprestsdk request blocked and response with "Failed to read HTTP status line" in a multi-threaded situation
body: <p>I have created a client server system server by following the <code>CppRestSdk</code> examples.</p>
  
  <p>Here is the sample code section of my implementation (only the request sending section).</p>
  
  <pre><code>nf.request(methods::POST, U("/"), requestBody)
      .then([=] (pplx::task&lt;http_response&gt; task)
      {
          LOG_ENTRY;
          // some other work ..
          resp = task.get(); // fails
          http_response resp;
          do {
              try {
  
                  resp = task.get();
              } catch (std::exception&amp; e) {
                  higLog("EXCEPTION CAUGHT: %s", e.what());
  
              }
  
              // some other checks ..
  
          }while(0);
  
         // process resp later ..
  
      }
  </code></pre>
  
  <p>where <code>nf</code> is a <code>http_client</code>.</p>
  
  <p>Here is the architecture of my system.</p>
  
  <p><a href="https://i.stack.imgur.com/0HbtZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0HbtZ.png" alt="architecture"></a></p>
  
  <p><a href="https://i.stack.imgur.com/ykg07.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ykg07.png" alt="thread_pool_call_flow"></a></p>
  
  <p>The main thread runs an <code>epoll</code> loop in the <code>front-end</code> server. It also creates an explicit <code>thread-pool</code>. The <code>epoll</code> loop receives the incoming messages from the client side and stores those messages in a work_queue (implemented by me). One of the threads (pool size of <code>500</code>) in the thread pool wakes up and picks a <code>job</code> from the work queue. This thread performs processing on the message and talks to <code>back-end</code> server using cpprestsdk <code>http_client</code> object.</p>
  
  <p>For a small number (<code>10</code> or <code>15</code>) of concurrent threads in the client side, the system works fine. But when I increase the number of threads (<code>50</code> threads for example) int the client side, the <code>front-end</code> server starts showings unpredictable errors. Mostly it blocks for a long time in the task.get() function. Sometimes it also shows "Failed to read HTTP status line" int he catch block. </p>
  
  <p>I am new to <code>cpprestsdk</code>. I am not sure what is happening really. But to my guess <code>backlog queue size</code> is small in the <code>back-end</code> server. I found a <code>set_backlog()</code> function, but I can not use it because of const reference. 
  <a href="https://github.com/Microsoft/cpprestsdk/blob/master/Release/include/cpprest/http_listener.h" rel="nofollow noreferrer">line 307</a>. </p>
  
  <p>What could be the reason for the above errors? It is common behavior? Is it because of <code>40</code> threads inside <code>cpprestsdk thread pool</code> ?</p>