title: Uncaught ErrorException: stream_socket_client(): SSL: Handshake timed out
body: <p>I'm trying connect to RabbitMQ from php.
  Here is my configuration after I followed instrctions here: <a href="https://www.rabbitmq.com/ssl.html" rel="nofollow noreferrer">https://www.rabbitmq.com/ssl.html</a></p>
  
  <p><strong>/etc/rabbitmq/rabbitmq.config</strong> </p>
  
  <pre><code>[
    {rabbit, [
       {password_hashing_module, rabbit_password_hashing_sha512},
       {ssl_listeners, [{"0.0.0.0", 5671}]},
       {ssl_options, [{cacertfile,"/var/www/rabbitmq/testca/cacert.pem"},
                      {certfile,"/var/www/rabbitmq/server/cert.pem"},
                      {keyfile,"/var/www/rabbitmq/server/key.pem"}
       ]}
     ]}
  ].
  </code></pre>
  
  <p>Using this php lib: <a href="https://github.com/php-amqplib/php-amqplib" rel="nofollow noreferrer">https://github.com/php-amqplib/php-amqplib</a></p>
  
  <pre><code>netstat -lpn | grep 5671
  tcp        0      0 0.0.0.0:5671            0.0.0.0:*               LISTEN      10420/beam.smp  
  </code></pre>
  
  <p>Php test script:</p>
  
  <pre><code>use PhpAmqpLib\Connection\AMQPSSLConnection;
  use PhpAmqpLib\Message\AMQPMessage;
  define('AMQP_DEBUG', true);
  $ssl_options = array(
    'cafile' =&gt; '/var/www/rabbitmq/testca/cacert.pem',
    'certfile' =&gt; '/var/www/rabbitmq/client/cert.pem',
    'keyfile' =&gt; '/var/www/rabbitmq/client/key.pem',
    'allow_self_signed' =&gt; true,
    'verify_peer' =&gt; true
  );
  $connection = new AMQPSSLConnection(
    '192.168.1.10',
    5671,
    'user',
    'pass',
    '/',
    $ssl_options);
  $channel = $connection-&gt;channel();
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>PHP Fatal error:  Uncaught ErrorException: stream_socket_client(): SSL: Handshake timed out in /var/www/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php:134
  </code></pre>
  
  <p>StreamIO.php line 134 is " $errno,":</p>
  
  <pre><code>try {
              $this-&gt;sock = stream_socket_client(
                  $remote,
                  $errno,
                  $errstr,
                  $this-&gt;connection_timeout,
                  STREAM_CLIENT_CONNECT,
                  $this-&gt;context
              );
          } catch (\ErrorException $e) {
              restore_error_handler();
              throw $e;
          }
  </code></pre>
  
  <p><strong>OS: Ubuntu 16.04</strong></p>
  
  <p><strong>PHP: 7.0.22</strong></p>
  
  <p>RabbitMQ log is empty when I execute this script.</p>