Random InvalidProviderToken Error

688 views
Skip to first unread message

kishore shetty

unread,
Apr 21, 2017, 2:07:05 AM4/21/17
to pushy
Hi all,

I am using pushy. Its working fine. But randomly i get InvalidProviderToken error ans stops working

I have doubt here 

Below lines of code is executed only once in our code. i.e during start up of our server.(Please read the comments added on each line)

Line1

apnsClient.registerSigningKey(new File("/path/to/key.p8"),"TEAMID1234", "KEYID67890", "com.example.topic"); 

// Do this line also need to be called only on startup.? I feel no as it says validity of token is one hour.
//Bcoz as per apple, do not generate a new provider authentication token for each push request that you send. After you obtain a token, continue to use it for all your push requests during the token’s period of validity, which is one full hour.

Line2:

final Future<Void> connectFuture = apnsClient.connect(ApnsClient.DEVELOPMENT_APNS_HOST); 

// As per apple, do not repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack


Please suggest.

Regards,
Kishore Shetty

Jon Chambers

unread,
Apr 21, 2017, 8:45:53 AM4/21/17
to kishore shetty, pushy
I think we're confusing a few separate ideas here.

First, there's a difference between a "signing key" and an "authentication token." Authentication tokens are created using a signing key, and Pushy handles all of that automatically. You only need to provide a signing key once (presumably at startup). After that, Pushy will generate new authentication tokens whenever the previous token expires.

Pushy will continue to use the same token until the server responds with `ExpiredAuthenticationToken`, at which point it will generate a new token automatically. This is all handled internally, and you don't need to do anything. You should never see a `Future` fail with `ExpiredAuthenticationToken` as the rejection reason.

I'm not sure why you're intermittently getting `InvalidProviderToken` rejections, but that sounds like a separate issue from authentication token expiration.

-Jon

--
Pushy is an open-source Java library for sending APNs (iOS and OS X) push notifications. Pushy is brought to you by the engineers at RelayRides.
---
You received this message because you are subscribed to the Google Groups "pushy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kishore shetty

unread,
Apr 24, 2017, 2:34:20 AM4/24/17
to pushy, kish...@gmail.com
Thanks Jon for resposne.
It makes sense now.

As per  log I can see when we got ExpiredProviderToken,Pushy handled it and gave call to Apple server.
Received response from APNs gateway: SimplePushNotificationResponse [pushNotification=SimpleApnsPushNotification [token=someToken, payload={"aps":{"alert":{"body":"some message"}}}, invalidationTime=null, priority=IMMEDIATE, topic=someTopic, apns-collapse-id=null], success=false, rejectionReason=ExpiredProviderToken, tokenExpirationTimestamp=null]
Received response from APNs gateway: SimplePushNotificationResponse [pushNotification=SimpleApnsPushNotification [token=someToken, payload={"aps":{"alert":{"body":"some message"}}}, invalidationTime=null, priority=IMMEDIATE, topic=someTopic, apns-collapse-id=null], success=false, rejectionReason=InvalidProviderToken, tokenExpirationTimestamp=null]

But question remains is why InvalidProviderToken? It works for some time. Then suddenly it stops working with InvalidProviderToken.

Note:
using com.relayrides:pushy:0.9

Code:
These below things we do at Start up:
apnsClient = new ApnsClientBuilder().setProxyHandlerFactory(proxyHandlerFactory).build();

apnsClient.registerSigningKey(new File(pathToKey), teamId, keyId, getTopic());

final Future<Void> connectFuture = apnsClient.connect(getApnsHost(), getApnsPort());
connectFuture.await();


These called at time of sending notification:
final Future<PushNotificationResponse<SimpleApnsPushNotification>> sendNotificationFuture = apnsClient
.sendNotification(getPushMessage(deviceToken,message,customPayloadData));

try {
final PushNotificationResponse<SimpleApnsPushNotification> pushNotificationResponse = sendNotificationFuture.get();

if (pushNotificationResponse.isAccepted()) {
return "Success";
} else {
String rejectionReason = pushNotificationResponse.getRejectionReason();
return pushNotificationResponse.getRejectionReason();
}
}//exception block

Please help.
To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+...@googlegroups.com.

Jon Chambers

unread,
Apr 24, 2017, 11:35:37 AM4/24/17
to kishore shetty, pushy
Two clarifying questions:

1. Once you start getting InvalidProviderToken errors, do ANY notifications go through, or do they ALL start failing?
2. Are you trying to use signing keys from multiple TEAMS on the same connection?

Thanks!

-Jon

To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+unsubscribe@googlegroups.com.

kishore shetty

unread,
Apr 25, 2017, 4:07:37 AM4/25/17
to pushy, kish...@gmail.com

Hi Jon,


1. Once you start getting InvalidProviderToken errors, do ANY notifications go through, or do they ALL start failing? -
No. Not until we restart the server.
Pattern Of issue:

Its many successful notification.

After sometime one ExpiredProviderToken, Then InvalidProviderToken always

Then again when we restart our server, again many successful notifications

After sometime one ExpiredProviderToken, Then InvalidProviderToken always


2. Are you trying to use signing keys from multiple TEAMS on the same connection?

No. 



We tried work around and it worked for us(Dont know exaclty how and why it worked. But it worked).

Instead of using below code at startup of server, We used it before sending notification(Usually after every hour),

apnsClient.registerSigningKey(new File(pathToKey), teamId, keyId, getTopic());


Now we are able to get notification successfully. Still keeping eyes on our logs.

Reply all
Reply to author
Forward
0 new messages