Mindbowser / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

API reports success but notification never delivered #80

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use javapns.test.NotificationTest with the batch file attached
2. API reports success (see output) below but the notification is never 
delivered
3. iPhone 4s, iOS5.
4. The same phone receives notifications using the same token and certificate 
using php code from 

What is the expected output? What do you see instead?
The output of javapns.test.NotificationTest is below:

java -cp 
./lib/javapns_2.0.jar;./lib/bcprov-jdk15-146.jar;./lib/log4j-1.2.16.jar 
javapns.test.NotificationTest IEMTransponder.p12 nph100463 
ca6bad86947f65d2d6938f80248c00938ada246c5c8a01525548bb39
5e62f5d3 production
0 [main] DEBUG javapns.devices.DeviceFactory  - Adding alert [Hello World!]
796 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSo
cketFactory
843 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating SSLSo
cket to gateway.push.apple.com:2195
1654 [main] DEBUG javapns.notification.PushNotificationManager  - Initialized Co
nnection to Host: [gateway.push.apple.com] Port: [2195]: 27b15692[SSL_NULL_WITH_
NULL_NULL: Socket[addr=gateway.push.apple.com/17.172.238.217,port=2195,localport
=49358]]
1654 [main] DEBUG javapns.notification.PushNotificationManager  - Building Raw m
essage from deviceToken and payload
1654 [main] DEBUG javapns.notification.PushNotificationManager  - Built raw mess
age ID 1
1654 [main] DEBUG javapns.notification.PushNotificationManager  - Attempting to
send notification: {"aps":{"alert":"Hello World!"}}
1654 [main] DEBUG javapns.notification.PushNotificationManager  -   to device: c
a6bad86947f65d2d6938f80248c00938ada246c5c8a01525548bb395e62f5d3
2106 [main] DEBUG javapns.notification.PushNotificationManager  - Flushing
2106 [main] DEBUG javapns.notification.PushNotificationManager  - Notification s
ent on first attempt
2106 [main] DEBUG javapns.notification.PushNotificationManager  - Reading respon
ses
2106 [main] DEBUG javapns.notification.PushNotificationManager  - Closing connec
tion
All notifications pushed successfully (1):
  [1] transmitted {"aps":{"alert":"Hello World!"}} on first attempt to token ca6
ba..2f5d3

What version of the product are you using? On what operating system?
Windows 7, API v2.0

Please provide any additional information below.

Original issue reported on code.google.com by maszc...@gmail.com on 7 Nov 2011 at 8:06

Attachments:

GoogleCodeExporter commented 8 years ago
From the log you provided, it seems that the payload is successfully 
transmitted to Apple servers and that no error-response packet is returned.  
The notification therefore does appear to have made it to Apple.  Now, why is 
Apple not delivering your notification, it's hard to say.

Have you tried using the development server?  Was it successful?  If so, could 
you copy-paste the log output for a test with the development server?

Original comment by sype...@gmail.com on 7 Nov 2011 at 8:19

GoogleCodeExporter commented 8 years ago
No I haven't yet. I'm working on the server side of the app so I need to ask my 
companion iPhone developers to have the dev code on one of their iPhones ready 
for me to test. I've only limited prod distribution on my phone. Will update 
once done.

Original comment by maszc...@gmail.com on 7 Nov 2011 at 11:01

GoogleCodeExporter commented 8 years ago
Additional note:  I just noticed that you are missing two required libraries 
(commons io and lang)...  I'm not sure how that could affect your 
notifications, but to be on the safe side, I'd add them..

Original comment by sype...@gmail.com on 7 Nov 2011 at 11:11

GoogleCodeExporter commented 8 years ago
Yes, I skipped them since it compiles and works without them. I added them now 
and no change- notifications are not delivered but code reports no errors. 
Which JVM are you testing against? I tried both 1.5 and 1.6 and the same 
results. Code thinks it's all OK but the phone never gets notified.
For sanity I just tried PHP test and bingo- notification delivered within 2 sec.

Original comment by maszc...@gmail.com on 8 Nov 2011 at 12:14

GoogleCodeExporter commented 8 years ago
Would you mind e-mailing me your keystore file so I can try it myself in debug 
mode?

I'm testing with Java 5 locally.

Out of curiosity.. the PHP test you did, is it using the enhanced notification 
format, or the simple one?  (just trying to find differences...)

Thanks!

Original comment by sype...@gmail.com on 8 Nov 2011 at 2:07

GoogleCodeExporter commented 8 years ago
HI tried the sandbox- same result. The library thinks it's all OK but the phone 
never gets the update.

I'm attaching p12 file for your test.

Original comment by maszc...@gmail.com on 8 Nov 2011 at 11:05

Attachments:

GoogleCodeExporter commented 8 years ago
the PHP script attach. This is the one that manages to get through to the 
phone. I think it's using simple format.

Original comment by maszc...@gmail.com on 8 Nov 2011 at 11:12

Attachments:

GoogleCodeExporter commented 8 years ago
CORRECTION!!!
The notification WORKED for sandbox! So the lib works if I use sandbox but does 
not when I use Apple production server. In both cases no errors are reported. 
For sandbox the notification ARE delivered to phone but for production they are 
NOT.

Another thing to note is that the PHP code does not use p12 file (you can see 
it if you open the code). So could it be the p12 keystore? But why doesn't the 
lib report any problems with connectivity?

Original comment by maszc...@gmail.com on 8 Nov 2011 at 1:04

GoogleCodeExporter commented 8 years ago
Could you provide the complete log output for your sandbox test (including the 
java command and parameters used to launch the test), so they can be compared?  
Thanks!

Original comment by sype...@gmail.com on 8 Nov 2011 at 3:17

GoogleCodeExporter commented 8 years ago
Just to confirm...  your tests with the PHP script are using "ckadhoc.pem", 
while your tests with JavaPNS are using "IEMTransponder.p12".  Do they contain 
the exact same certificate and private key?   Or are they different 
certificates?  Which server were they generated for (sandbox or production)?

If they are different certificates, which one is the iApp built with?  Your 
iApp would only receive notifications for one of them, not both.  The library 
might not get any error if both certificates are valid and tokens appear to be 
valid, but that doesn't mean that your iApp would receive your notifications if 
they are not sent with the same certificate your iApp is built with.

Original comment by sype...@gmail.com on 8 Nov 2011 at 4:31

GoogleCodeExporter commented 8 years ago
Problem solved! :-)

The issue was that the original certificat file I was using IEMTransponder.p12 
had keys/certificats for both production and sandbox servers. For some reason 
the API always picked up the sandbox keys. For some reason they worked while 
connecting to Apple productionbut ultimately the notifications were not 
delivered.
We produced new certificaes just for production servers and it solved the 
problem- messages are now delivered.

Thanks for support- I was impressed by the speed of response. Well done guys! 

Original comment by maszc...@gmail.com on 8 Nov 2011 at 10:43

GoogleCodeExporter commented 8 years ago
Good news!  I will add this little detail to the documentation :)

Thanks!

Original comment by sype...@gmail.com on 8 Nov 2011 at 10:48