SOLVED Limiting inbound call length to 3 mins only.

GerryGerry

Member
Joined
Dec 26, 2015
Messages
57
Reaction score
9
I've been searching this forum (and google) and have only managed to find info on limiting inbound calls to a predefined time limit INCLUDING the ringing time. Can anyone here point me in the right direction to limiting call duration timed from the point the call is answered?

As I want to limit time to only 3 mins, if this includes the ring time (and sometimes it can ring for > 30 seconds) it will make large inroads to the allowed time.

Any help much appreciated as always.
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,607
Reaction score
826
Hehe I was there in that thread, that was a while ago !!.

To do that absolute timeout you would need to add that set statement AFTER the channel is answered , and in the channel the call is bridged to, just as @briankelly63 suggested, but be careful the inbound call might end up in a number of contexts, and you are in an area where there might not be a useful *custom.conf, you might need to go the "override" path or add a macro for calls into such channels.
 

krzykat

Telecom Strategist
Joined
Aug 2, 2008
Messages
3,145
Reaction score
1,235
Been a while since I was in this stuff, but I'd recommend taking a look over at A2Billing, because it does just that. You should be able to find out from them how to do it, and alternatively, I'd recommend asking @jroper - he'll know the answer.
 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
Hi

To the dial command parameters, add either L(x,y,z) (x duration in milliseconds, y and z are timings for warnings that the call is about to be disconnected,) or you want S(T) where T is the time in seconds to disconnect the call.

More information about the dial command parameters at https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_Dial, including how to use the L options.

Against the trunk in FreePBX, you will see a field marked "Asterisk Trunk Dial Option" where you can put the above settings as part of the dial command, i.e.

S(180)
Will disconnect the call 3 minutes after answer

L(180000)
Will also disconnect the call 3 minutes after answer as well.

You can also add these globally in the settings page, but that will affect all calls.

Joe
 

GerryGerry

Member
Joined
Dec 26, 2015
Messages
57
Reaction score
9
Hi

To the dial command parameters, add either L(x,y,z) (x duration in milliseconds, y and z are timings for warnings that the call is about to be disconnected,) or you want S(T) where T is the time in seconds to disconnect the call.

More information about the dial command parameters at https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_Dial, including how to use the L options.

Against the trunk in FreePBX, you will see a field marked "Asterisk Trunk Dial Option" where you can put the above settings as part of the dial command, i.e.

S(180)
Will disconnect the call 3 minutes after answer

L(180000)
Will also disconnect the call 3 minutes after answer as well.

You can also add these globally in the settings page, but that will affect all calls.

Joe
Thank you so much for taking the time to reply, but I'm still unclear where to enter these so that they effect incoming calls (I have outgoing duration restrictions working using a custom context for various extensions relying on the dial parameters as you suggest)
 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
Hi

I should have read the title a bit more carefully. Same principle, assuming calls always go to the same destination.

Create a context called [limit-calls-3mins] in /etc/asterisk/extensions_custom.conf with a dial command as previously stated, and using the local channel, dial the destination.

[limit-calls-3mins]
exten => _X.,1,Dial(local/600@from-internal,60,S(180))

- _X. ;; _ says pattern match, X is a number from 0 to 9, and . is anything
- 1 is the priority - always starts with 1, subsequent lines are numbered n
- Local is the channel to use
- 600 is the extension to call
- from-internal is the context where internal extensions live
- 60 is how long to ring out for
- S(180) is how long to keep the call up when answered.

Then in Custom Destinations, add Context,Extension,Priority, e.g. limit-calls-3mins,${EXTEN},1 then point your inbound DID to this new custom destination in inbound routes.

The call will come into inbound routes in the normal way, go to the context above, then dial extension 600. Enhance, secure, modify and test to meet your needs.

Joe
 

GerryGerry

Member
Joined
Dec 26, 2015
Messages
57
Reaction score
9
Hi

I should have read the title a bit more carefully. Same principle, assuming calls always go to the same destination.

Create a context called [limit-calls-3mins] in /etc/asterisk/extensions_custom.conf with a dial command as previously stated, and using the local channel, dial the destination.

[limit-calls-3mins]
exten => _X.,1,Dial(local/600@from-internal,60,S(180))

- _X. ;; _ says pattern match, X is a number from 0 to 9, and . is anything
- 1 is the priority - always starts with 1, subsequent lines are numbered n
- Local is the channel to use
- 600 is the extension to call
- from-internal is the context where internal extensions live
- 60 is how long to ring out for
- S(180) is how long to keep the call up when answered.

Then in Custom Destinations, add Context,Extension,Priority, e.g. limit-calls-3mins,${EXTEN},1 then point your inbound DID to this new custom destination in inbound routes.

The call will come into inbound routes in the normal way, go to the context above, then dial extension 600. Enhance, secure, modify and test to meet your needs.

Joe
First of all thanks again for your help. I tried your suggestion, and at first it would not even ring the extension. After examining my asterisk logs I saw that it was trying to connect to the S extension so the pattern _X. was not matching.
I fixed this by adding :-
exten => S,1,Dial(local/101@from-internal,60,L(1000))​
to the context.

However although my extension now rings and I can pickup the call, the time limit is completely ignored. Even more odd is that the logs show and I quote:

[2016-07-26 17:47:45] VERBOSE[17449][C-00000113] pbx.c: Executing [s@limit-calls-10secs:2] Dial("SIP/zzz.zzz.zzz.zzz-0000016a", "local/101@from-internal,120,L(1000)") in new stack
[2016-07-26 17:47:45] VERBOSE[17449][C-00000113] features.c: Setting call duration limit to 1.000 seconds.
[2016-07-26 17:47:45] VERBOSE[17449][C-00000113] app_dial.c: Called local/101@from-internal


I think perhaps the from-internal context has its own 'Dial' command which effectively resets anything passed to it from before. Is there a way to overcome this or is an entirely different solution needed?

 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
Hi

I guess you were just using a catchall pattern for the DID in inbound routes. If you properly enter your DID in inbound routes, you will have to return that dialplan to _X., as the extension won't match the s extension, but the logs will tell you that.

The logs will tell you whether there is another dial command executed, but I doubt it. Attach or pastebin the logs and we can look as well.

The logs do suggest that a call duration limit is being set, so why it's not happening is not clear, but a one second (1000ms) duration is very short.

You might try with the S(t) directive to terminate the call, because if you are not using the features of the L(x,y,z) dial command, then you probably should not introduce that complexity.

Maybe if you gave us a heads up on what you are trying to achieve from the business perspective, e.g. why do you want the call to hang-up, then we could suggest another solution.

Joe
 

GerryGerry

Member
Joined
Dec 26, 2015
Messages
57
Reaction score
9
Hi let me address things point by point
I guess you were just using a catchall pattern for the DID in inbound routes.
Correct, it on a 'new' cloud PBX system built just for testing and this. It is the both the default and only inbound route. please note I added the exten => S not replaced so other inbound routes when defined should also work.
a one second (1000ms) duration is very short.
This was just for testing purposes (so I don't have to wait too long each time)
You might try with the S(t)
I did do this originally as per your post but it was ignored as well.
Maybe if you gave us a heads up on what you are trying to achieve from the business perspective
The system is to be used for a specialist help line with rather limited access hours. During opening hours we'd like to 'help' as many people as possible. To this end if we could force each call to a maximum for 3 - 5 mins we could cater for 10 people an hour per operator (of which there are 2!)

Just a little more info which may be helpful the timeout variable of the Dial command is interpreted correctly so if not answered withing 60 secs it does hangup.

Thanks again
Gerry
 
Last edited:

GerryGerry

Member
Joined
Dec 26, 2015
Messages
57
Reaction score
9
Here is the new 'limiting context'
[limit-calls-10secs]
exten => _X.,1,noop(Limiting maximum call duration to 5 seconds)
exten => _X.,n,Dial(local/101@from-internal,120,S(5))
exten => s,1,noop(Limiting maximum call duration to 5 seconds)
exten => s,n,Dial(local/101@from-internal,120,S(5))

I have sent you the logs 'unsanitized' in a PM
 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
Hi

I see you just pasted them in to the PM. I find them really difficult to read like that, as the lines are wrapped, there is no colour, it's best if you either pastebin or attach them.

What did you work out from reading the logs, any conclusions?

Joe
 

GerryGerry

Member
Joined
Dec 26, 2015
Messages
57
Reaction score
9
I don't see how to attach anything here in the forum so I've put it on pastebin (link in PM).
I do see in the logs that just before the extension is rung it does use a 'new' Dial command (log extract below):-
[2016-07-27 15:14:24] VERBOSE[3995][C-00000000] pbx.c: Executing [s@macro-dial-one:43] Macro("Local/101@from-internal-00000000;2", "dialout-one-predial-hook,") in new stack
[2016-07-27 15:14:24] VERBOSE[3995][C-00000000] pbx.c: Executing [s@macro-dialout-one-predial-hook:1] MacroExit("Local/101@from-internal-00000000;2", "") in new stack
[2016-07-27 15:14:24] VERBOSE[3995][C-00000000] pbx.c: Executing [s@macro-dial-one:44] Dial("Local/101@from-internal-00000000;2", "SIP/101,,tr") in new stack
[2016-07-27 15:14:24] VERBOSE[3995][C-00000000] netsock2.c: Using SIP RTP TOS bits 184
[2016-07-27 15:14:24] VERBOSE[3995][C-00000000] netsock2.c: Using SIP RTP CoS mark 5
[2016-07-27 15:14:24] VERBOSE[3995][C-00000000] app_dial.c: Called SIP/101
[2016-07-27 15:14:24] VERBOSE[3987][C-00000000] app_dial.c: Local/101@from-internal-00000000;1 is ringing


 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
Hi

You were right, there are further dial commands, try

exten => s,1,noop(Limiting maximum call duration to 5 seconds)
exten => s,n,Dial(SIP/101,120,S(5))

So we call the SIP endpoint directly, by passing the from-internal context.

Joe
 

GerryGerry

Member
Joined
Dec 26, 2015
Messages
57
Reaction score
9
You were right, there are further dial commands, try

exten => s,1,noop(Limiting maximum call duration to 5 seconds)
exten => s,n,Dial(SIP/101,120,S(5))

So we call the SIP endpoint directly, by passing the from-internal context.
Perfect!!
Thank you so much
 

Members online

Forum statistics

Threads
25,779
Messages
167,505
Members
19,199
Latest member
leocipriano
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top