Agi-mqtt with FREEPBX not just Asterisk?

FreePBX 14.0.5.25
Asterisk 13.20.0 built by root @ raspbx on a armv6l running Linux on 2018-04-03 18:02:05 UTC

Your pasted calls are going to from-trunk, not the context you created

D’oh. I am a complete novice at all this. I’m sorry. I didn’t realise that [from-pstn-mqtt] should be replaced with my own context.

Woohoo! Progress!

So now I’ve got this:-

Executing [[email protected]:1] AGI("SIP/1-pstn-00000016", "/opt/agi-mqtt/mqtt,/opt/agi-mqtt/mqtt.cfg,calls/pstn-in") in new stack
    -- Launched AGI Script /opt/agi-mqtt/mqtt
    -- <SIP/1-pstn-00000016>AGI Script /opt/agi-mqtt/mqtt completed, returning 0

however my broker is showing NO attempted connections from the script/pi. This is probably the limit of where this wonderful forum can help really. I’ve reached out to the developer but he’s not responded yet. I use no authentication on my MQTT broker and I’m not sure how to do that with this script. I’ve left the fields in the config file totally blank but that doesn’t seem to be doing the trick. Oh well, it was great to get this far and I’m sure with a bit more fiddling I’ll get all the way.

THANK YOU!!

Turn on agi logging at the asterik cli

-- Launched AGI Script /opt/agi-mqtt/mqtt
<SIP/1-pstn-00000018>AGI Tx >> agi_request: /opt/agi-mqtt/mqtt
<SIP/1-pstn-00000018>AGI Tx >> agi_channel: SIP/1-pstn-00000018
<SIP/1-pstn-00000018>AGI Tx >> agi_language: en
<SIP/1-pstn-00000018>AGI Tx >> agi_type: SIP
<SIP/1-pstn-00000018>AGI Tx >> agi_uniqueid: 1559921212.66
<SIP/1-pstn-00000018>AGI Tx >> agi_version: 13.20.0
<SIP/1-pstn-00000018>AGI Tx >> agi_callerid: 01639628331
<SIP/1-pstn-00000018>AGI Tx >> agi_calleridname: LANDLINE
<SIP/1-pstn-00000018>AGI Tx >> agi_callingpres: 0
<SIP/1-pstn-00000018>AGI Tx >> agi_callingani2: 0
<SIP/1-pstn-00000018>AGI Tx >> agi_callington: 0
<SIP/1-pstn-00000018>AGI Tx >> agi_callingtns: 0
<SIP/1-pstn-00000018>AGI Tx >> agi_dnid: 01639628847
<SIP/1-pstn-00000018>AGI Tx >> agi_rdnis: unknown
<SIP/1-pstn-00000018>AGI Tx >> agi_context: from-trunk
<SIP/1-pstn-00000018>AGI Tx >> agi_extension: 01639628847
<SIP/1-pstn-00000018>AGI Tx >> agi_priority: 1
<SIP/1-pstn-00000018>AGI Tx >> agi_enhanced: 0.0
<SIP/1-pstn-00000018>AGI Tx >> agi_accountcode:
<SIP/1-pstn-00000018>AGI Tx >> agi_threadid: 1924797472
<SIP/1-pstn-00000018>AGI Tx >> agi_arg_1: /opt/agi-mqtt/mqtt.cfg
<SIP/1-pstn-00000018>AGI Tx >> agi_arg_2: calls/pstn-in
<SIP/1-pstn-00000018>AGI Tx >>
-- <SIP/1-pstn-00000018>AGI Script /opt/agi-mqtt/mqtt completed, returning 0

The only other thing I can think of is that I am running node-red on the same Pi - and listening out for MQTT commands on that - perhaps they might not be able to be run concurrently?

Presumably

/opt/agi-mqtt/mqtt.cfg

Will reflect your brokers identity.

It does, yes.

tcpdump -vv port 1883

If the host is 127.0.0.1

tcpdump -i lo port 1883

and

lsof -i :1883

1 Like

The broker is hosted on another Raspberry Pi, so I don’t know if this is the right approach, but I installed Wireshark, set the MQTT script IP to my MacBook’s and tried to trigger the script with an inbound call. Nothing. So I don’t THINK the script is actually ‘working’. Yeah, great technical term there, dan_ce! What I mean is, I don’t think the script execution is proceeding to the point where it attempts to make a TCP/IP connection. Hmmm. I wish I could just call the script (with the same arguments) directly from bash because then maybe it would print some useful diagonistic info back.

If you are out of your depth, then perhaps

might be simpler to debug, it uses mosquitto_pub to connect to your broker, not a long unsupported library from somewhere. It also runs well on a raspberry.

I’m definitely out of my depth. I also think I’ve answered @jfinstrom, the script I think is broken with current version of python.

When I run it, I get “ImportError: No module named mosquitto”. I think I need to attempt to move the script over to Paho

Possibly an even bigger “over my head” there migrating a python script, how comfortable are you with python?

In bash
mosquitto_clients (mosquitto_pub/sub)

are all you need to make sure you you can see, publish and subscribe to your broker’s available topics , until facile with all that then I think you will find it all a long row to hoe.

Thanks, Dicko. I really appreciate your help today. I’ll see how I get on. At the moment I’m playing with your most recent suggestion. :slight_smile:

WAS JUST ABOUT TO GIVE UP AND GOT IT WORKING!! THANKS @DICKO!!
(sorry to shout).

COOL!!!

By the way, it = your simpler mosquitto method - I had to tweak the code slightly but all good!!

2 Likes

Please elucidate, We always appreciate peer review . .

[from-trunk]
exten => _X.,1,trysystem(mosquitto_pub -h 192.168.2.11 -t 'calls/in/${EXTEN}' -m  '${CALLERID(num)}' )
exten=> _X.,n,Goto(from-pstn,${EXTEN},1)
[your-custom-mqtt-inbound]
exten => s,1,trysystem(mosquitto_pub -h your.mqtt.broker -t 'your/topic/${EXTEN}' -m ${CallerID(number)} )
exten=> s,n, goto(from-pstn,${EXTEN},1)

The main change was to the capitalisation of the CallerID/CALLERID (it seemed to matter!).
Thank you! So happy to get this working.

1 Like

Just fyi, this is probably the reason pastebin didn’t work. I assume it’s a distro feature.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.