hello,
I'm using the AWS SNS for sending push notifications for iOS and android devices.
Currently I'm working on the android version of my app, and when I try to use the AWS SNS for registering endpoints to my platform application I get :
SignatureDoesNotMatch: Signature expired: 20161010T120646Z is now earlier than 20161010T151154Z (20161010T152654Z - 15 min.)
Now, the iPhone app is almost done, and I didn't get that error when working on the iPhone version.
I'm using the same credentials, meaning, same IAM user which has two policies attached to him.
One for APNS and one for GCM (Firebase).
I use the same Mac to work on both apps, so it's the same time zone. Why it doesn't work, please?
Thanks.
The error occurs here (marked with double stars) :
var params = {
PlatformApplicationArn: my application, /* required */
Token: data.registrationId, /* required */
CustomUserData: 'OrUser',
Attributes: {
Enabled: 'true',
}
};
**sns.createPlatformEndpoint(params, function(err, data)** {
if (err) {
console.log(err,err.stack); // an error occurred
}
else {
console.log(data); // successful response
localStorage.setItem('EndPointARN', data.EndpointArn); // Store localy
registerDeviceOnServer(localStorage.getItem('registrationId'), localStorage.getItem('EndPointARN'));
}
});
Hi @OrZipori
This could be an issue with your clock not being synced correctly. See:
https://github.com/aws/aws-sdk-js/issues/401
https://github.com/aws/aws-sdk-js/issues/527
Make sure your clock is correct. You can also pass an option into the service client to correct any clock skew for you:
var sns = new AWS.SNS({correctClockSkew: true});
If that still doesn't work, what version of the SDK are you using? Looking through our issue history, it looks like updating the version of the SDK has resolved the problem for some.
https://github.com/aws/aws-sdk-js/issues/265
https://github.com/aws/aws-sdk-js/issues/254
Let me know if neither correcting the clock skew nor updating the SDK version works.
Thanks...
var sns = new AWS.SNS({correctClockSkew: true});
Fixed it...But why there's an error in the first place?
Hi @OrZipori
This error occurs when your clock is significantly out of sync with the server, which will cause your signature to be invalid. If you want to reliably reproduce this error on any computer, just change the computer's clock to be a time that you know is incorrect, and send a request to any AWS service.
When you set correctClockSkew to true, the SDK, upon receiving this error, will find the difference between the time on your clock and the time sent back by the server in the response header, and will resign the request with the corrected time and retry the request. Also, the time difference is cached, so any subsequent requests will automatically be corrected on the first try.
I'm glad to hear that your issue is fixed. Let me know if you have additional questions.
Yes I have another question concerning push notification.
I'm using SNS for push notifications for android and iOS. Since sending to both devices require different platform application, my endpoints are saved separately. How do I send push notification to all endpoints via SNS publish api in on request instead of many, please?
I've read that using Topics would give me that result, but from what I read, I need them (users) to accept (confirm) that they would like to get notifications..Isn't it going to complicate things, since users already accept notification when app first started?
Thanks.
restarting docker daemon fixed it
sudo systemctl start docker
or
sudo service docker start
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Most helpful comment
Hi @OrZipori
This could be an issue with your clock not being synced correctly. See:
https://github.com/aws/aws-sdk-js/issues/401
https://github.com/aws/aws-sdk-js/issues/527
Make sure your clock is correct. You can also pass an option into the service client to correct any clock skew for you:
If that still doesn't work, what version of the SDK are you using? Looking through our issue history, it looks like updating the version of the SDK has resolved the problem for some.
https://github.com/aws/aws-sdk-js/issues/265
https://github.com/aws/aws-sdk-js/issues/254
Let me know if neither correcting the clock skew nor updating the SDK version works.