I'm going crazy with Apple push notifications! I developed my application and checked the notifications after Ray Wanderlich , and everything worked fine until I changed the distribution .pem file and changed the connection string from gateway.sandbox.push-apple.com to gateway.push-apple.com.
Now, if I try to send a message, the server will return
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out) Failed to connect: 110 Connection timed out
The php file and .pem file are in TMDHosting: I try to ask them if port number 2195 is closed, because googling I found that the error means that the port is closed.
Although, I canโt understand if the error is related to the certificate or server.
The strange thing is that if I follow the procedure with Terminal to test the .pem file, everything seems to work
CONNECTED(00000003) depth=1 /C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C verify error:num=20:unable to get local issuer certificate verify return:0 --- Certificate chain 0 s:/C=US/ST=California/L=Cupertino/O=Apple Inc/OU=Internet Services/CN=gateway.push.apple.com i:/C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C 1 s:/C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C i:/O=Entrust.net/OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)/OU=(c) 1999 Entrust.net Limited/CN=Entrust.net Certification Authority (2048) --- Server certificate -----BEGIN CERTIFICATE----- MIIEXTCC.......... -----END CERTIFICATE----- subject=/C=US/ST=California/L=Cupertino/O=Apple Inc/OU=Internet Services/CN=gateway.push.apple.com issuer=/C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C --- No client certificate CA names sent --- SSL handshake has read 2541 bytes and written 2039 bytes --- New, TLSv1/SSLv3, Cipher is AES256-SHA Server public key is 1024 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE SSL-Session: Protocol : TLSv1 Cipher : AES256-SHA Session-ID: Session-ID-ctx: Master-Key: CBA98981BB512ED2FDF0C003F4556FDDA564BEBBEFC6528C37D8E0336BC141AEC6D7E014568B334B8330FFFE266E8CB4 Key-Arg : None Start Time: 1332945845 Timeout : 300 (sec) Verify return code: 0 (ok) ---
This allows me to think that this is not a .pem problem ...
I am wrong?
I already read all the similar questions and tried to change the port number from 2195 to 30, but nothing changes. Tips
EDIT : I found that it seems equal to my problem: TMDHosting told me
... you are in a collaborative environment and opening a port for you will not be possible. However, note that the address you connect to port 2195 is not associated with our server. In other words, you are trying to establish a connection with a remote server on port 2195. To make this connection to the port indicated above, you must make sure that the port is open for incoming connections on the remote server, and not on the server that your account relies with us.
Do I need a VPS?
EDIT2
In the tutorial that I followed, I found
.. you will need a server connected to the Internet. From myself, notifications are always sent by the server. For development, you can use your Mac as a server (which is good to do in this tutorial), but for production, you need at least something like VPS (Virtual Private Server). A cheap shared hosting account is not good enough. You should be able to start the background process on the server, install an SSL certificate and be able to make outgoing TLS connections to some ports. Most hosting providers do not allow you to do this, although they can, if you ask. However, I really recommend using a VPS like Linode.
Finally, I think I need a VPS. Can you confirm this for sure? But why, if I send a push notification from a sandbox server, does it work correctly without VPS?
LAST UPDATE : (I hope something helped someone) it seems that an error has occurred, because it is correct that I can not send push notifications not to the sandbox, but to the production server from my hosting (TMDHosting): my shared hosting not open for port 2195. Changed provider: everything works.