Outgoing SMS with Amazon SNS
9 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: April 25, 2020 (RSS)
By gversion - October 25, 2019
Hello,
I am trying to set up the Outgoing SMS plugin with Amazon SNS (I have been using textlocal successfully but the pricing is just too high now!). The error I am receiving is:
Sender - RequestExpired - Request timestamp is too skewed. Timestamps must be within 900 seconds of server time. Timestamp date: 2019-10-25T14:05:46
From a bit of reading I think this because the SNS service is using the endpoint "sns.us-east-1.amazonaws.com" however my server timezone is different (GMT London) so I tried changing the endpoint to "sns.eu-west-2.amazonaws.com" (taken from here: https://docs.aws.amazon.com/general/latest/gr/rande.html).
Unfortunately I am still receiving the same error message...
Can someone please advise? I would be very grateful for any suggestions.
Also, for OUTGOING_SMS_GATEWAY_USERNAME_OR_API_KEY and OUTGOING_SMS_GATEWAY_USERNAME I have inserted my Access Key ID and for OUTGOING_SMS_GATEWAY_PASSWORD_OR_API_KEY_SECRET and OUTGOING_SMS_GATEWAY_PASSWORD I have inserted my Secret access key.
Regards,
Greg
By gversion - October 29, 2019
sns.eu-west-2.amazonaws.com does not support SMS sending. I had to change it to sns.eu-west-1.amazonaws.com
Now it works!
By gversion - April 15, 2020
Hello,
I am having this same error again. I believe it's something to do with the fact the clocks have recently gone forward in London.
When I run "date"at the SSH command prompt I can see the correct time based on the timezone "Europe/London". However when I run "wget -S "https://mydomain.com""the time is one hour behind. I don't understand why there is a difference.
Can you please tell me how to update the time that is returned by running wget -S "https://mydomain.com"? I think I need this to be forward an hour and then the issue should be resolved.
UPDATE: I have read here: https://stackoverflow.com/questions/42296659/by-using-http-request-how-to-get-servers-timezone-not-in-utc-format
The HTTP header will only give you the time in UTC/GMT. This part of the HTTP specification, in RFC7231 section 7.1.1.1 and 7.1.1.2.
So maybe this can't be updated... in which case I am still not sure what to do to fix this!
Any help would be hugely appreciated.
Regards,
Greg
ps. mydomain.com is a placeholder, I am using my real domain when running the command!
By gversion - April 15, 2020
In MySQL I ran "select @@system_time_zone" and UTC was returned. Maybe if I change this to BST then it will work.
I am not sure how to change this though on an RDS instance (ideally via PhpMyAdmin) so if anyone can advise that would be great!
Regards,
Greg
By gversion - April 15, 2020 - edited: April 15, 2020
OK, I have managed to get the SMS messages to send by updating the outgoingSMS plugin code as follows:
$timeStamp = date("Y-m-d\TH:i:s");
$bstTime = date('Y-m-d\TH:i:s',strtotime('-1 hour',strtotime($timeStamp)));
I then pass through the $bstTime for the "Timestamp" in the $urlVariables array.
At least it now works but could anyone help me identify what time setting is wrong on my server set up please? I do not really want to have to use this custom modification as I will no doubt need to remove my custom code when the clocks go back on 25th October 2020!!
Thanks as always,
Greg
By Dave - April 15, 2020
Hi Greg,
There's probably a few things going on. The server account that you login with via SSH may be different from the account that PHP and/or Apache runs as, and they all can have different default timezone settings.
We let users specify the timezone under Admin > Settings > Regional Settings > Timezone Name. What this does is set PHP's default timezone with the date_default_timezone_set() function. This affects the date returned when you call PHP's date function.
Having a quick look at the Amazon SMS code it doesn't look like we're sending a timezone identifier. I suspect that if Amazon supported us sending a timezone as well that would resolve everything. Without that you'd need to connect to an amazon server that was in the same timezone as you or it's going to think your time is off.
Hope that helps, we'll take a look into this further and see if there's a patch we can add to resolve it.
Hope that helps!
interactivetools.com
By gversion - April 15, 2020
Hi Dave,
Thanks for the reply.
I checked the settings in cmsb and my timezone is set to "Europe/London", which is what I want however I have just noticed it says "GMT+00:00" which is not correct as the clocks have gone forward by an hour. Is that a problem with the dropdown options you are offering?
See attached.
Regards,
Greg
By gregThomas - April 24, 2020
Hey Greg,
I've resolved the issue with the Outgoing SMS plugin when using the AWS SNS service, the timestamp in the API call needed to be in UTC format, this is the reason it stopped working when the clocks changed. I've also added a new setting to the plugin that allows the SNS server to be changed easily. I've emailed you a copy of the updated plugin and will release it early next week.
I've also resolved the issue that was causing the timezone offset for Great Britain to be incorrect in the CMS General Settings menu, this fix will appear in the next CMS Builder release.
Thanks!
PHP Programmer - interactivetools.com