1
function getConnection($certPemFile)
{
    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', $certPemFile);
    $dsn = 'ssl://'.'gateway.push.apple.com:2195';
    $socket = stream_socket_client($dsn, $errno, $errMsg, 3, (STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
    if(!$socket) {
        printf("errno=%d  errMsg=%s", $errno, $errMsg);
    }
    return $socket;
}

I connect to the APNS server with this code, but sometimes it returns $errno=0 and $errMsg=''.

I have updated the .pem files.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Aaron
  • 11
  • 2
  • See also https://stackoverflow.com/questions/24928311 – Alexis Wilke Nov 03 '17 at 02:34
  • Possible duplicate of [stream\_socket\_client failing on my server with no way to know more about the error](https://stackoverflow.com/questions/24928311/stream-socket-client-failing-on-my-server-with-no-way-to-know-more-about-the-err) – Robbie Aug 28 '18 at 07:10

0 Answers0