Apn PHP Code Giving Warning: Stream_Socket_Client() [Function.Stream-Socket-Client]: Unable to Connect to Ssl://Gateway.Sandbox.Push.Apple.Com:2195

APN php code giving Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195

Assuming your server has the right ports open, "Connection Refused" usually hints at an invalid .PEM file or an incorrect passphrase. Make sure that when you open the .PEM file, the header looks something like this :

Bag Attributes
friendlyName: Apple Development IOS Push Services: com.yourapp.app
localKeyID: A8 77 BC 0C 2E 81 10 6E 78 9F XX XX XX XX XX XX

subject=/UID=com.yourapp.app/CN=Apple Development IOS Push Services: com.yourapp.app/C=FR
issuer=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority

followed by a key which should then be followed by a header that looks like this for your private key :

Bag Attributes
friendlyName: Joe Black
localKeyID: A8 77 BC 0C 2E 81 10 6E 78 9F XX XX XX XX XX XX XX XX
Key Attributes: <No Attributes>

I suggest you also remove the passphrase to reduce the potential error sources.

How to use Apple Push Notifications if you can't use port 2195?

In order to send the notifications to the device need to enable 2195 port in the firewall.
For security reasons some organizations disabling these ports in the firewall.
2196 port is used for feedback services and this port also should open in the firewall.
Without opening these ports messages cannot deliver to APNS.

PHP fails socket connection with Apple notification gateway

Some random finding from the internet which could help:

  1. It may be a certificate problem. Try the stream options allow_self_signed and verify_peer to check that.

  2. Try to use explicitely sslv2:// or sslv3:// ?

  3. Permission problem on "/dev/urandom"

stream_socket_client unable to connect (connection timed out)

I had fixed the issue by opening the port 2195 on the production server. You can verify by following command $telnet gateway.push.apple.com 2195

-bash-3.2# telnet gateway.push.apple.com 2195

Trying 17.149.38.141...
Connected to gateway.push.apple.com (17.149.38.141).
Escape character is '^]'.
Connection closed by foreign host.


Related Topics



Leave a reply



Submit