I am experimenting with Apple Push Notification Service with node.js as server. So far I've got it to work and when it works, it works as intended.
However, sometimes the message doesn't arrive. I am not sure if this is natural (maybe I have bad connection and the message is not coming through because of that), or if it's a bug in my code. The situation is really random. Sometimes it comes through and sometimes it doesn't, even though I didn't change the code or anything.
I am using node-apn (https://github.com/argon/node-apn), and according to the debug console, it's being registered as successfully going through--at least from the server side. Here's the debug message:
apn Initialising connection +19s
apn Initialising module +1ms
apn Connection established +383ms
apn Sending notification +0ms
apn Socket drained +1ms
apn Socket writeable +0ms
This message appears both when the message goes through and when it doesn't go through. So I guess node-apn itself is doing its job all right. Which means it's either:
There's something happening between my server and apple push server
There's something happening between apple push server and my iOS device
But I don't know how to find out what's happening. So what I am trying to find is a solution to:
Find out if my push notification is being registered by APNS
Find out if APNS is sending out all the notifications to my iDevice
Anyone know how to do this? Thank you so much!
There is a well written technical note from Apple about the different sources of problems with the push notification services:
http://developer.apple.com/library/ios/#technotes/tn2265/_index.html
Use tcpdump on ports 2195, 2196 and 5223, as data pass over them:
http://support.apple.com/en-us/HT202944
Use Wireshark to read the dump files:
http://redmine.streamco.org/projects/smartswitch-public/wiki/Debug_VoIP_call_with_Wireshark
Related
Good day people!
I started having this problem last month when the registered devices on my app stopped receiving push notifications
At first I realized that it was because Apple dropped SSL v3 support so I performed a git pull of the pyapns update.
Push messages started sending properly again, but are not being received. The push server logs are returning few malformed payload errors, but the occurrence of a successfully sent notification is very low, and sometimes being sent in batches.
After rebuilding the push certificate, push messages started being sent on time, and successfully, but this only lasted for a few hours.
As of now, a direct push notification test request to my server is not even being delivered to test devices properly, which was not the case a few hours back.
This is my setup:
All push messages are queued via Resque.
Actual server pushing the payload is 'pyapns.'
Push server OS is Ubuntu 14.04.1 LTS.
Upon checking logs on my service, Resque, and pyapns, I was very sure that I am successfully sending the payload to the Apple push servers. There are no malformed payload responses from APNS, but still, no messages.
Push certificate is recently updated and is being used by server running pyapns.
A quick peek at the server shows that a copy of Entrust CA Root Certificate is installed (as per requirement for TLS connections, specified by Apple).
Can anyone help me in this problem? Thank you!
How did you
I updated my push server application to use TLS instead.
PyAPNs should auto switch to TLS without any further configuration. Please refer to PyAPNs TLS support, it contains openssl test command as well :)
I developed a web API for my mobile app use it.
This API was developed with Django, and I'm using the django-push-notifications lib to handle the push notifications.
The push notifications were working fine for all the devices, until it stopped working for few of them, which worked at some point, for no apparent reason.
I already debugged the server and I can see the messages being sent to APNS and on the correct format. Also reviewed the certificates, and all is working as it should. I'm using the production certificate sending to the appropriate server.
I'm sure that this is not a problem with certs, since some other phones receive the notifications.
Where should I start looking for the problem now?
Thanks.
They are not reliable! There is no guarantee that push notifications will actually be delivered, even if the APNS server accepted them.
As far as your server is concerned, push notifications are fire-and-forget; there is no way to find out what the status of a notification is after you’ve sent it to APNS. The delivery time may also vary, from seconds up to half an hour.
Also, the user’s iPhone may not be able to receive push notifications all the time. They could be on a WiFi network that does not allow connections to be made to APNS because the required ports are blocked. Or the phone could be turned off.
See this link
Are you sure that those some devices does't have a development version of app ?
Try to generate a combined p12 certificate of apn development certificate and apn production certificate , than try to call gateway.push.apple.com and gateway.sandbox.push.apple.com separately.
Is there a way to send the APNs a push notification for clients without using the socket opening method? If I could just send the parameters with an HTTP Post that should be pretty easy, but I can't seem to find anything indicating this is possible.
I'm using Google AppEngine for my server, and I've been wrestling with opening up a socket (even had a different thread here for that) for a couple days now, and it seems useless.
Thanks
No, apple use a SSL connection, with certificates, to send Push message.
You might be able to use a third party API to push via HTTP.
I would like to understand the cycle of APNS with my web server to receive push notification. I open the port 2195 from my webserver in the (out side), do I need another port to open it in my sever to receive the push notification??? because still not received it.
please help!
Yes, port 2195 open. With APNS, you only send out things. Apple doesn't send you anything back unless you're using the feedback gateway, which I guess is not your case...
Your server do not receive push notifications. It only sends requests to Apple, which then sends notifications to iOS devices or MacOS desktops.
If your device did not receive and your server code is being able to establish a connection with apple, much probably your push cert is not uploaded to your server or it has permission problems or it was not properly generated at your iOS dev website.
p.s. if you're sending OUT things, your port logically should be open from inside (outbound) in your server
I have this strange problem with iOS Push Notifications:
I configured my server to send push notifications, yet sometimes they are not delivered.
In order to get them back to work on a specific device, I have to turn OFF the Wi-Fi and switch it back ON. After that the message is received.
I'm still trying to put my finger on that issue, without luck.
More Info:
1.Server is working in sandbox mode.
2.Development certificates are in use.
3.Other notifications still works while mine won't (Facebook, Whatsapp).
In my theory, there are some differences between test APNS server, and real APNS server.
I do not think that is your problem.
Log something after send a message to APNS server
Try to take off the sandbox and set it to false.
Check your certificates.. if you have ad hoc certificate, notifications will only work when you create an IPA and install it on your device. Or if you download the app from the applestore.
Another issue can may cause your problem is the Data traffic.
If your phone does not have internet unless it connects to wifi, the device doesn't recive the push notification until it is not connected to wifi.
Hope it helps.