title: SSL_Connect hangs when connecting to some proxies on Synapse
body: <p>I have a multi-threaded software that loops through a <code>TStringList</code> of HTTP URLs using the <code>HTTPMethod</code> method of the <code>THTTPSend</code> object... However, a bug started to appear with proxies -- less with good private proxies, more with bad public proxies. Now and then, a few threads would hang and become 100% unresponsive. The timeout setting and the <code>heartbeat</code> code would be ignored; no exceptions would be raised. No matter how long I would wait (up to 10 minutes), the threads would still be hanging. Closing the software was the only way to stop the threads.</p>
  
  <p>I found out that the incriminated method was <code>SSL_Connect</code>. From what I've read, this hanging behavior can be corrected by using non-blocking sockets (<a href="https://stackoverflow.com/questions/11835203/openssl-ssl-connect-blocks-forever-how-to-set-timeout">openssl ssl_connect blocks forever - how to set timeout?</a>)</p>
  
  <p>The thing is, Synapse is a blocking sockets library. I could always use a non-blocking sockets library for this small software, but I would like to implement SSL protocol to some of my bigger software. I cannot afford to change all their code for another Internet library that is likely to have its own bugs anyway.</p>
  
  <p>How can I set some sort of timeout for <code>SSL_Connect</code> while still using Synapse?</p>
  
  <p><em>There is no code because everything is very straightforward. It's a TStringList of URLs being looped -- nothing else! However, if you think it's needed (or if you need any other kind of information), tell me.</em></p>
  
  <p><strong>Delphi used:</strong> 2007</p>
  
  <p><strong>Version of Synapse used:</strong> release 40 (2012) (<em>Edit:</em> The bug still exists with the latest SVN trunk download.)</p>
  
  <p><strong>Version of OpenSSL used:</strong> 1.0.1e</p>