My solution for implementing Flowroute SMS into Asterisk

(United States) #23

Ok, Thanks for that info. This is what I get…

file_get_contents( failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request\r\n in /var/www/html/sms/out.php on line 39

(Simon Telephonics) #24

Double check you put the right API token in the file (line 20).

(Dave Burgess) #25

I do a lot of PHP programming, and a white screen is almost always a “compile” error. @billsimon probably hit it on the head - I’d bet there’s something in the encryption chain that jacking you up.

(United States) #26

That is supposed to the profile secret correct?

If so, it is indeed correct. I even re-created my profile and re-copied the secret and get the same error.

(Simon Telephonics) #27

Messaging - Messaging Profile - API v1 - APIv1 Profile Secret

If that’s correct, then investigate other logs etc.

If you have iptables or distro firewall restricting access, make sure you are allowing Telnyx to connect to your PBX on port 443 (https). And of course make sure you have a valid certificate (no self-signed).

If you don’t see any logs in /var/log/asterisk/full when you try to send or receive SMS then you might need to get on the asterisk console and increase verbosity.

In the apache access log confirm that you are seeing hits from Telnyx to telnyx.php for inbound SMS or hits on out.php from your own server for outbound.

As you can see there are many parts and that’s my heap of guesses; start with those and dig in.

(United States) #28

It is correct

All Telnyx IP’s are trusted. Using a Let’s Encrypt Cert

There is a host of log lines in the Asterisk Log file


Attached is the full asterisk log with a few lines below that may be pertinent

[2021-04-22 07:09:10] DEBUG[5177] devicestate.c: No provider found, checking channel drivers for PJSIP - SMS
[2021-04-22 07:09:10] DEBUG[5177] manager.c: Running action ‘Command’
[2021-04-22 07:09:15] DEBUG[28932] res_pjsip/pjsip_distributor.c: Could not find matching transaction for Request msg MESSAGE/cseq=1 (rdata0x7ff6602e8d18)
[2021-04-22 07:09:15] DEBUG[28932] res_pjsip/pjsip_distributor.c: Calculated serializer pjsip/distributor-00000031 to use for Request msg MESSAGE/cseq=1 (rdata0x7ff6602e8d18)
[2021-04-22 07:09:15] DEBUG[17937] res_pjsip_endpoint_identifier_ip.c: Source address 172.XX.XXX.XXX:51783 does not match identify ‘Telnyx’
[2021-04-22 07:09:15] DEBUG[17937] res_pjsip_endpoint_identifier_ip.c: Source address 172.XX.XXX.XXX:51783 does not match identify ‘SMS’

And near the end:
[2021-04-22 07:09:16] DEBUG[28907][C-00000db3] stasis/messaging.c: No subscription found for PJSIP/501
[2021-04-22 07:09:20] DEBUG[4974] threadpool.c: Worker thread idle timeout reached. Dying.
[2021-04-22 07:09:20] DEBUG[4973] threadpool.c: Worker thread idle timeout reached. Dying.

And the pertinent log lines from access and error logs

Access Log line - 159 IP Address is the correct PUBLIC IP Address of the FreePBX Server

159.XX.XX.XXX - - [22/Apr/2021:07:09:16 -0400] “POST /sms/out.php?to=717XXXXXXX&from=1717XXXXXXX HTTP/1.1” 200 - “-” “asterisk-libcurl-agent/1.0”

Error Log Line:

[Thu Apr 22 07:09:16.392814 2021] [:error] [pid 11007] [client 159.XX.XX.XXX:46296] PHP Warning: file_get_contents( failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request\r\n in /var/www/html/sms/out.php on line 39

Many thanks to anyone that could help me out in understanding why this is failing.

Asterisk Full Log.tgz (2.8 KB)

(Simon Telephonics) #29

It seems like a problem with your configuration at Telnyx. To confirm, you have that 717 DID enabled for SMS and your account with Telnyx is verified to be able to send SMS?

If I look at the properties for my number, Routing tab, I see:

(United States) #30

Thanks for your reply. Here is a snippet from Telnyx.

Also, if I go through the “Learn and Build” steps at Telnyx it will send an SMS to my cell number.

(Simon Telephonics) #31

I tested a couple failures.

If I use the wrong token it gives an HTTP 403.

If I use an invalid caller ID it gives HTTP 400 Bad Request.

Your Asterisk log showed that it is setting an 11-digit SMS caller ID,

"Using external caller ID of 1717XXXXXXX"

but the script is expecting to receive a 10-digit number (national standard). That’s the account code field - just take the 1 off the front and try again.

(United States) #32

Interesting. I changed my Telnyx settings from E.164 to National and now my outbound texts work, but inbound still don’t work.

I’ve looked though the Asterisk log files and it appears to “think” it delivered the message, but nothing comes though.

I also noticed this in my http error log:
PHP Notice: Trying to get property of non-object in /var/www/html/sms/telnyx.php on line 24

incoming asterisk full log.tgz (2.5 KB)

(Simon Telephonics) #33

The script I provided wants you to use 10-digit DID in the accountcode field and E.164 formatting in Telnyx. If you change it around you might have to adjust the script accordingly.

Looking at your asterisk log it says the message was successfully delivered to pjsip 501. Do you have multiple registrations turned on for 501? I don’t think it will work in that scenario. Otherwise, you could collect Groundwire logs to see what’s going on.

(United States) #34

Ok thanks for the suggestion. I have multiple registrations turned on (which is necessary for push notifications to work I believe.) I had also been testing a few services like Ringotel and ClearlyIP using this extension. I suspect one of those was still registering. I changed my extension secret to prevent any registrations other than my own and it immediately started working.

Thanks for all your help.