Apple Push notification not working on shared server

I want to send APN (Apple Push Notification) from a PHP script. My PHP script works fine, and I get a notification on the iphone device, as well as when sending from localhost, but when I upload the same script with the same .pem file to the shared server , it returns an error ...

 Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195 (Connection refused) in /mypath/SendPushNotification.php on line 28 Failed to connect: 111 Connection refused 

From some source, I learn that for sending the APN port 2195 must be open, which is impossible in terms of a common server. So I tried to use a dedicated server, and it works fine, and I get a notification on the device. I tried very hard to find a solution for the shared server, but did not find any solution.

My question is: is it possible to send an APN without opening port 2195 from a shared server? if yes give some recommendations.

+3
source share
3 answers

No, it is not possible to send an APN message without using port 2195.

If you want to send a push notification from a shared server, try using some third-party tools, such as http://urbanairship.com/ .

+3
source

Some time ago I had the same error, and after that I discovered that it occurs because of the server, the proxy blocks this port, because most servers do not use this port as a common one (80 or 21),

In this case, you can try to ask support from your server reseller, they can open this port (2195) for you. If you take this decision, I would also recommend asking open port 2196 that the port is used for feedback.

Another solution is to use a free push notification provider such as Parse, which is really easy to use and implement in your application, you can also use UrbanAirship, but I prefer Parse;)

Hope this helps

+1
source

This is annoying and certainly port 2195 issue. Chat with your hosting provider and ask them to open the port. I had the same problem too. My local code worked peacefully in every state, such as sandbox and production , but it did not work on the server.

Do not confuse the path to the .pem file, and this will just match your code. For me, I placed my certificates (.pem) in a directory named certs and gave the path as follows:

 $apnsCert = 'certs/cert_prod.pem'; 

The code did not work on my application production server. I wasted a day and a half for this, but it did a great job on the first run when I put it on the middleware server. Cause!!!! Definitely port 2195 problem.

All the rhythms.

0
source

Source: https://habr.com/ru/post/987189/


All Articles