Infinity Lenny

Hi all,
I setup Lenny with a virtual extension so that users had an extension to transfer spam/nuisance inbound calls to. In this example -ext 1099. Lenny has done his job reducing those calls.
I had an user that wanted to test Lenny.
The user direct dialed Lenny at 1099.
Lenny answered and started talking.
The user then either put Lenny on hold and did an assisted transfer (or did a blind transfer) to 1099.
The transfer was successful and the user hung up their phone.
This created a 23,39,396,524 bytes long .wav file with a duration of 146,265 seconds (40+ hours or 1.6 days)
I opened the .wav file and found that Lenny was talking to Lenny!
At some point 40+hours later, the Lennys synched up, both became silent, which caused the normal time out and stopped the recording.

I have a couple questions.
Q1. How can you check the PBX to show call(s) in progress?
Q2. How do you cancel/stop/quit a call in progress?

If a Lenny call goes more than xx number of minutes then the PBX should stop the call.
Q3. Is there a way to limit the length of a call?

Thank you,

LOL :joy:

A1A. You might try inspecting the Reports → Asterisk Info display page.
A1B. Or, Admin → Asterisk CLI then type in and execute “core show channels

A2. Hanging up calls in progress can be done from the Admin → Asterisk CLI then typing “channel request hangup <channel>” (see command’s relevant documentation).

A3. One way to add a call duration limit is in the Asterisk Dial Options under Settings → Advanced Settings and therein include option S(x) to “Hang up the call x seconds after the called party has answered the call.”

If this is an incoming call from the PSTN and it answers with Lenny, there’s no called party at that point, no Dial has happened.

Doesn’t seem that way… per OP:

But seeing some dial plan and logs would help clear things up.

If there is a dial involved it will work but if there are multiple extension this needs to apply to then updating the global dial options to include the S(x) option is the better way.

Is there any good guilds out there any of you would recommend to install Lenny on v17?

I would like to provide dial plan and logs, but I don’t know how to do that.
Can you provide instructions?
Thank you,

The custom Lenny dial plan is in your extensions_custom.conf file, yes ?

Relevant logs would (probably) be from /var/log/asterisk/full file during the time of this call, or, make a new call during (slow) hours, then grab the logs.

Once you inspect the parts to scrub out any Personal Information (PI) e.g. dialed PSTN numbers, names, IP addresses, etc., then you can paste in our https://pastebin.freepbx.org site.

penguinpbx,
Thank you for the instructions. Getting the Lenny’s dial plan is easy. Parsing the relevant full log is is not easy for a couple reasons.
The dial started on one day and finished 1.6 days later.
There are two PBXs involved that are bridged together over a pjsip trunk.
I can’t reproduce what the user did and the user doesn’t remember what they did.
I appreciate all the help, but I think I chasing a problem that most likely won’t happen again. (never say never)
I will do some more investigating but this has turned into a can of worms.
Thank you,

This link helped me. Maybe it will help you.

I want to say that I am not affiliated with Crosstalk. I got permission from them before posting their link.

Somewhere early in the Lenny dialplan add a line that sets the timeout like

exten => xxx,n,Set(TIMEOUT(absolute)=YYYY)

YYYY is a value in seconds. Set the x’s to match whatever the exten already is in your dialplan.

Here is snippet from my /etc/asterisk/extensions_custom.conf file. I added your line and set YYYY to 3600seconds (1 hour), but I don’t what to set ‘xxx’ to.
How do I find what the ‘exten already in my dialplan’ is?

[Lenny]
exten => xxx,n,Set(TIMEOUT(absolute)=3600)
exten => talk,1,Set(i=${IF($["0${i}"="016"]?7:$[0${i}+1])})
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

Thank you,

You can’t have n before 1, and I presume they mean “talk”.

I changed the order and added ‘talk’.
Is this correct?

[Lenny]
exten => talk,1,Set(i=${IF($["0${i}"="016"]?7:$[0${i}+1])})
exten => talk,n,Set(TIMEOUT(absolute)=3600)
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

Thank you,

No. This dialplan is weird, it loops and increments a counter from 1 to 16, then restarts again at 7 to 16 ad infinitum. Your diaplan will reset the timeout continuously, I think this will work:

[Lenny]
exten => talk,1,Set(i=${IF($["0${i}"="016"]?7:$[0${i}+1])})
same => n,ExecIf($[${i}=1]?Set(TIMEOUT(absolute)=3600))
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))
same => n,Playback(Lenny/Lenny${i})
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)

I would share this with the original author, as it creates a real possibility of a stuck channel with an ever growing recording file.

I am not new to programming, but I am new to asterisk dial plan syntax. I understand what the Lenny dial plan is doing, but I don’t understand how the looping is done. I don’t see a while() or other looping syntax. Why does the dial plan loop? Does the code just go back to the top of [Lenny} when the last line is executed?
Thank you,

My thanks to kingarthur for his input. The below TIMEOUT is set to 600 (10 minutes), which is about enough time for Lenny to loop twice. I want experiment with adding while() and Hangup() but for now the following gets the job done.

[Lenny]
exten => talk,1,Set(i=${IF($["0${i}"="016"]?7:$[0${i}+1])}) ; if (i = 16) then (i = 7) else (i + 1)
same => n,ExecIf($[${i}=1]?MixMonitor(${UNIQUEID}.wav))     ; if (i = 1) then start recording the call. recording should be located at /var/spool/asterisk/monitor
same => n,ExecIf($[${i}=1]?Set(TIMEOUT(absolute)=600))      ; if (i = 1) then set the channel timeout to avoid the channel being stuck
same => n,Playback(Lenny/Lenny${i})                         ; playback the Lenny(i).wav file, when playback is complete then continue
same => n,BackgroundDetect(Lenny/backgroundnoise,1500)      ; start playback of backgroundnoise and listen for non-silence followed by silence of 1.5 seconds then stop playback and continue

When dealing with Asterisk dialplan, the excellent Asterisk documentation often provides more insight:

Not automatically, no. The BackgroundDetect() dial plan application is redirecting the call only when talking is detected.

Ah-ha!
I wondered why the [Lenny] dial plan extension is named ‘talk’.
I carefully re-read the BackgroundDetect() description.
“…the audio playback is aborted and processing jumps to the ‘talk’ extension, if available.”
So, when BackgroundDetect() completes, it jumps to ‘talk’ because it exists in the dial plan.
Thank you for clearing that up.
I can sleep better tonight!

1 Like

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