oleg82 / javapns

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

invalid token error #220

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi..

I encountered "invalid token error"

It works find at sandbox but failed at production.

and thanks anyway :-)

==========

What steps will reproduce the problem?
> using command line test tools (notification, feedback)

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
> on MacOS

Please provide any additional information below.

> notification tool

==========
command : 

java -cp "JavaPNS_2.2.jar:lib/bcprov-jdk15-146.jar:lib/log4j-1.2.15.jar" 
javapns.test.NotificationTest keystore_for_distribution.p12 Pass**** 
d7d2********************************************************5c36 production

==========
log : 

Validating keystore reference: VALID  (keystore was found)
Verifying keystore content: VERIFIED  (no common mistakes detected)
0 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating 
SSLSocketFactory
25 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating 
SSLSocket to gateway.push.apple.com:2195
2122 [main] DEBUG javapns.notification.PushNotificationManager  - Initialized 
Connection to Host: [gateway.push.apple.com] Port: [2195]: 
69d95da8[SSL_NULL_WITH_NULL_NULL: 
Socket[addr=gateway.push.apple.com/17.172.234.192,port=2195,localport=49579]]
2124 [main] DEBUG javapns.notification.PushNotificationManager  - Building Raw 
message from deviceToken and payload
2138 [main] DEBUG javapns.notification.Payload  - Adding alert [JAVAPNS DEBUG 
ALERT 1
2014/10/15 11:53:17
gateway.push.apple.com
D7D2¡¦5C36 [Id:1] Exp:T+86400
Enhanced format / UTF-8]
2138 [main] DEBUG javapns.notification.PushNotificationManager  - Built raw 
message ID 1 of total length 191
2139 [main] DEBUG javapns.notification.PushNotificationManager  - Attempting to 
send notification: {"aps":{"alert":"JAVAPNS DEBUG ALERT 1\n2014/10/15 
11:53:17\ngateway.push.apple.com\nD7D2\u20265C36 [Id:1] Exp:T+86400\nEnhanced 
format / UTF-8"}}
2139 [main] DEBUG javapns.notification.PushNotificationManager  -   to device: 
d7d2********************************************************5c36
3962 [main] DEBUG javapns.notification.PushNotificationManager  - Flushing
3962 [main] DEBUG javapns.notification.PushNotificationManager  - At this 
point, the entire 191-bytes message has been streamed out successfully through 
the SSL connection
3962 [main] DEBUG javapns.notification.PushNotificationManager  - Notification 
sent on first attempt
3963 [main] DEBUG javapns.notification.PushNotificationManager  - Reading 
responses
4604 [main] DEBUG javapns.notification.PushNotificationManager  - Found 0 
notifications that must be re-sent
4605 [main] DEBUG javapns.notification.PushNotificationManager  - No 
notifications remaining to be resent
4605 [main] DEBUG javapns.notification.PushNotificationManager  - Closing 
connection
All notifications failed (1): [1] transmitted {"aps":{"alert":"JAVAPNS DEBUG 
ALERT 1\n2014/10/15 11:53:17\ngateway.push.apple.com\nD7D2\u20265C36 [Id:1] 
Exp:T+86400\nEnhanced format / UTF-8"}} on first attempt to token d7d22..75c36  
APNS: [1] Invalid token  
javapns.notification.exceptions.ErrorResponsePacketReceivedException: An error 
response packet was received from the APNS server: APNS: [1] Invalid token

==========

> feedback tool

==========
command : 

java -cp "JavaPNS_2.2.jar:lib/bcprov-jdk15-146.jar:lib/log4j-1.2.15.jar" 
javapns.test.FeedbackTest keystore_for_distribution.p12 Pass**** 
d7d2********************************************************5c36 production

==========
log :

0 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating 
SSLSocketFactory
24 [main] DEBUG javapns.communication.ConnectionToAppleServer  - Creating 
SSLSocket to feedback.sandbox.push.apple.com:2196
2752 [main] DEBUG javapns.feedback.FeedbackServiceManager  - Found: [0]

==========

Original issue reported on code.google.com by cafew...@gmail.com on 15 Oct 2014 at 3:26

GoogleCodeExporter commented 9 years ago
Is this a token for a sandbox device?  If you search the web for "apns invalid 
token production", you will find a lot of info pointing to a possible mixup 
with your sandbox and production tokens and/or certificates.  I suggest you 
clear that up, as it is most likely the problem (because the error you are 
seeing is actually coming from Apple, so there's not much the library can 
do...).

Original comment by sype...@gmail.com on 16 Oct 2014 at 3:03

GoogleCodeExporter commented 9 years ago
well.. that token from just parsed param "devToken" in method 
"didRegisterForRemoteNotificationsWithDeviceToken: (NSData *) devToken"

are there any different ways to get each tokens?

thanks for your comment and effort, keeping this useful lib. :-)

Original comment by cafew...@gmail.com on 16 Oct 2014 at 4:39

GoogleCodeExporter commented 9 years ago
I meant, are you using a sandbox app to get that token?  If you are, that token 
is apparently only usable through the APNS sandbox servers.

Original comment by sype...@gmail.com on 17 Oct 2014 at 4:40

GoogleCodeExporter commented 9 years ago
yes it was.. now problem solved.
thanks a lot :-)

Original comment by cafew...@gmail.com on 19 Oct 2014 at 1:46

GoogleCodeExporter commented 9 years ago
Closing as per confirmation that this was not an issue with JavaPNS.

Original comment by sype...@gmail.com on 28 Oct 2014 at 7:19