title: Unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error)
body: <p>I have a question about Apples Push Service. 
  What do following warnings exactly mean?</p>
  
  <blockquote>
    <p>Warning: stream_socket_client(): Failed to enable crypto in /opt/../xyz.php on line 150</p>
    
    <p>Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /opt/../xyz.php on line 150</p>
  </blockquote>
  
  <p>I am using about 5 different php files for sending push (<code>AddFriendPush</code>, <code>ChatMessagePush</code>...) to the iOS Devices and they are working fine. But sometime I get these warnings and I don't know what they mean but push doesn't work when I get these warnings..</p>
  
  <p>I know that they can appear if your pem file is wrong or the port 2195 is blocked. But push works sometimes and sometimes it doesn't. So the pem file has to be right and the port can't be blocked.</p>
  
  <p>I know it is not good to have 5 different scripts for push, I will change it soon. </p>
  
  <p>Do you have any idea what is going on? </p>
  
  <p>My php scripts look like this: </p>
  
  <pre><code>function sendPush($deviceToken, $msg)
  {
      $deviceToken = $deviceToken;
      $passphrase = 'passhrase';
  
      $ctx = stream_context_create();
      stream_context_set_option($ctx, 'ssl', 'local_cert', 'Production.pem');
      stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
  
      $fp = stream_socket_client(
          'ssl://gateway.push.apple.com:2195', $err,
          $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
  
      if (!$fp) {
          unset($con);
          exit(); 
      }
  
      //do the other stuff
  
      //Close the connection to the server
      fclose($fp);
  }
  </code></pre>