title: ios Push Notification not working on the server
body: <p>I tested push notification on my local machine, it is working perfectly. I then uploaded my files to the real server with the same certificate (".pem" file), and I ensure that the ports 2195 and 2196 are open.</p>
  
  <p>I tested:</p>
  
  <pre class="lang-none prettyprint-override"><code>telnet gateway.sandbox.push.apple.com 2195
  </code></pre>
  
  <p>It is working...</p>
  
  <pre class="lang-none prettyprint-override"><code>root@server ~ # telnet gateway.sandbox.push.apple.com 2195
  
  Trying 17.149.34.54...
  
  Connected to gateway.sandbox.push.apple.com.
  
  Escape character is '^]'.
  </code></pre>
  
  <p>But when I test from my php script, it returns:</p>
  
  <blockquote>
    <p>Warning: stream_socket_client() [function.stream-socket-client]:
    unable to connect to ssl://gateway.sandbox.push.apple.com:2195
    (Connection timed out)</p>
    
    <p>Warning: stream_socket_client() [function.stream-socket-client]:
    unable to connect to ssl://feedback.sandbox.push.apple.com:2196</p>
  </blockquote>
  
  <p>Any suggestions?</p>
  
  <hr>
  
  <p>This is the php code:</p>
  
  <pre><code>$ctx = stream_context_create(); 
  
  stream_context_set_option($ctx, 'ssl', 'local_cert',
     "path/to/certificate"); 
  
  $fp = stream_socket_client("ssl://gateway.push.apple.com:2195",
     $error, $errorString, 100,
     (STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
  </code></pre>