SMSC - HTTP Connection with Twilio | Search |
NowSMS Support Forums ⬆ NowSMS Support - SMS Issues ⬆ |
◄ ► |
Author | Message | |||
Pointer Telocation New member Username: Moshetal Post Number: 6 Registered: 10-2020 |
Hi Support, I'm using the thhp option with Twilio I need to enter Username and password in order to authenicate and send sms. I entered Account SID (as Username) and Auth Token (As Password) - but no Luck. Getting Invalid username and password error. Which king of User and Pass should i use? Why the Authentication is failing? See attached. | |||
Pointer Telocation New member Username: Moshetal Post Number: 7 Registered: 10-2020 |
Hi, Getting HTTP status code = 400 when sending SMS test message. Please assist | |||
Bryce Norwood - NowSMS Support Board Administrator Username: Bryce Post Number: 8408 Registered: 10-2002 |
Hi, Twilio (and HTTP services in general) can be difficult to debug, because there is a lot of variety in how they report errors. NowSMS can judge success or failure based on the HTTP status code, but that doesn't tell you much. It is often helpful to enable the SMSDEBUG.LOG (via setting on the Serial # page), and then look at this log to determine the reason for the failure. I just activated a Twilio account for testing, and experienced the same two issues that you encountered above ... so I can explain the issues that you are encountering. The "invalid user name or password" error is because Twilio expects the credentials to be sent using the HTTP Authorization headers, so that option must be enabled. The "HTTP Status code = 400" error presented these details in my SMSDEBUG.LOG: 12:22:29:181 [53] ThreadProcessModem: HTTP/1.1 400 Bad Request Date: Sun, 07 Mar 2021 17:22:29 GMT Content-Type: application/xml Content-Length: 255 Connection: keep-alive Twilio-Request-Id: xxxxxxxxxxxxx Twilio-Request-Duration: 0.047 Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since Access-Control-Allow-Methods: GET, POST, DELETE, OPTIONS Access-Control-Expose-Headers: ETag Access-Control-Allow-Credentials: true X-Powered-By: AT-5000 X-Shenanigans: none X-Home-Region: us1 X-API-Domain: api.twilio.com Strict-Transport-Security: max-age=31536000 <?xml version='1.0' encoding='UTF-8'?> <TwilioResponse><RestException><Code>21603</Code><Message>A 'From' phone number is required.</Message><MoreInfo>https://www.twilio.com/docs/errors/21603</MoreInfo><Status>400</Status></RestException></TwilioResponse> I could see from these details that the issue was that the service requires a "From" ("Sender") address to be set. So, I had to buy (rent) a phone number from Twilio, and apply this as the "Sender Address" for the SMSC connection in NowSMS. I was able to send and receive messages after making that change. Regards, Bryce Norwood NowSMS Support | |||
Bryce Norwood - NowSMS Support Board Administrator Username: Bryce Post Number: 8409 Registered: 10-2002 |
As we seem to be having some problems with our search functionality ... I'm reposting an old message that explains some Twilio setup issues, particularly as it also explains how receive functionality works. --- Define an HTTP SMSC in NowSMS, and for "Server Type", select Twilio. Enter the Account SID as "User Name", and the Auth Token as "Password". The Twilio phone number should be defined as the "Sender Address". Uncheck the various options except for "Send long messages without segmentation", which should be checked. Set routing parameters as appropriate for your system. Here's an example: To receive inbound SMS from Twilio, you need to configure an SMS URL in your phone number settings in Twilio. If your NowSMS server is accessible over the internet, use http://server:8800/inboundsms/twilio If not, don't worry as NowSMS will poll Twilio every 30 seconds for new messages. However, our experience is that this polling only works if you have a URL defined for inbound SMS on Twilio, otherwise Twilio discards the message. In the past I've used a URL of http://twilio.com to get around this. NowSMS uses a set of templates to define how it interacts with Twilio. You can find the Twilio template under the NowSMS install at HTTPSMSC/Twilio If you decide to modify any of these templates, I'd suggest copying the 3 files from HTTPSMSC/Twilio to a new directory under HTTPSMSC, and select that as the "Server Type" in the HTTP SMSC definition. This way, if we update the default template in a new version, it will not affect your setup. Regards, Bryce Norwood NowSMS Support | |||
Pointer Telocation New member Username: Moshetal Post Number: 8 Registered: 10-2020 |
Hi Bryce - thank you so much for the solution above!! One question: If i want that the From(Sender) will not appear as Number and i want it it be a text, like: Alerts From Pointer. How do i achieve that? | |||
Bryce Norwood - NowSMS Support Board Administrator Username: Bryce Post Number: 8410 Registered: 10-2002 |
Hi, In all cases, this is dependent on what the service provider (and the mobile operators) allow. What you are asking about is known as an “alphanumeric sender”. Support for alphanumeric senders used to be quite common, but it has fallen out of favor in some countries, because it is not possible for receivers of the message to reply. Twilio is US based, and a requirement in the US is that if you are sending out automated text messages, you must allow recipients to reply STOP to be removed from your lists. If “Allow Sender Address Override” is NOT checked, NowSMS will always apply the configured sender address to outbound messages sent via that connection. If “Allow Sender Address Override” is checked, NowSMS will use the sender address if one is not specified (for example, the test message feature that you were having trouble with earlier), but if a different sender address is specified in the message, NowSMS will use that instead. However, the provider may have strict rules about what sender addresses they will accept. Regards, Bryce Norwood NowSMS Support | |||
Pointer Telocation New member Username: Moshetal Post Number: 9 Registered: 10-2020 |
Hi Bryce and thanks again for your helpful and detailed answers :-) 1 more question: do you know where i can: our experience is that this polling only works if you have a URL defined for inbound SMS on Twilio, otherwise Twilio discards the message. In the past I've used a URL of http://twilio.com to get around this. Where on Twilio code i can modify it?}} | |||
Bryce Norwood - NowSMS Support Board Administrator Username: Bryce Post Number: 8411 Registered: 10-2002 |
Hi, Sorry, but I'm not an expert on that service... Until yesterday, I hadn't had reason to login to an account on the service in almost 5 years. What I am referring to is a setting, not code. So, it would be located somewhere in your account settings on their website. I believe they call it a web hook. In my experience years ago, they would not deliver messages to you via polling unless you had a web hook defined. My server was not directly internet accessible, so it was not possible to define it as a web hook, so I just used an otherwise valid URL that would ignore it. In retrospect, that was an ugly hack on my part, and I would not recommend that for a production app. A better approach would be to create your own script to either process the message, or to ignore the message and let NowSMS discover the message via polling. Regards, Bryce |