Error with APNS Server using PHP

Asked

Viewed 74 times

1

I created a small APNS Server using PHP, using an older version of Xampp. However when I went to use the push file in a current version, I received the error as per the image:

inserir a descrição da imagem aqui

The error line that is referenced above is this:

// Servidor de produção0
$fp = stream_socket_client( 'ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

I believe that the stream_socket_client function is outdated, as I am not an expert in the field of PHP, I wonder if this is the problem, and if it is, how could replace or update this function.

  • Error says certificate check failed.

1 answer

1


I ran some tests:

  • Using Xampp 5.6 -> Presented the error reported in the question
  • Using the Mac Console (Native PHP with version 5.5) -> Worked normally
  • Using Xampp 5.5 -> Also worked normally.

    I believe that some configuration or update in Xampp 5.6 is affecting access to the *.pem file on disk, making it impossible to create connection with APNS.

    If anyone knows this problem in version 5.6 and know the solution I appreciate if you comment or complement this solution I found.

Thank you all!

  • Fala ae @Tiago then dude, I created a code very similar to yours, but apple returns me $err = 0, "Failed to connect: 0", would you know what this could be? (I hosted my php on a free host site "ptblogs.com")

  • 1

    Pow, as far as I know, the ports that APNS uses to receive the push are blocked on hosts of websites (2195 and 2196). You would need to either put this on a machine in your home, or use a large service like AWS or Azure to have a virtual machine. But in this case, AWS and Azure have this service ready.

  • the problem was with my door, where it did not connect with the port of the APNS, so I climbed to a server, worked perfectly, I appreciate the feedback

Browser other questions tagged

You are not signed in. Login or sign up in order to post.