How to Minimize Channels Used in Outgoing Calling via AMI Originate in Asterisk

Hello Team,

Hope you are doing well.
Greeting day to all.

I would like to share one Asterisk Problem which is related to channel consumption.
I’m generating Outgoing Call via Asterisk AMI in which first Call used Local Channel then outgoing call dialled on User Phone, if he picks the call custom Dial plan will run else disconnect the call.
In this Model total Three Channels has been consumed from starting to till then user received call, my point is to Minimize used channels of SIP.

Let me share you AMI code which I used for Outgoing:

fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: $user\r\n");
fputs($socket, "Secret: $pass\r\n\r\n");
fputs($socket, "Action: Originate\r\n" );
fputs($socket, "Channel: Local/$calling_number@outbound-ami-status/n\r\n" );
fputs($socket, "Exten: $calling_number\r\n" );
fputs($socket, "Context: outbound\r\n" );
fputs($socket, "Priority: 1\r\n" );
fputs($socket, "Callerid: XXXXXX\r\n" );
fputs($socket, "WaitTime: 5\r\n" );
fputs($socket, "Variable: variable_id=$variable_id\r\n");
fputs($socket, "Async: true\r\n" );
fputs($socket, "Action: logoff\r\n\r\n" );

Below is my DialPlan code for Local SIP:

     exten => _X.,1,NoCDR()
        same => n,Dial(SIP/${EXTEN}@outbound,15,m(adg-hold-music))
        same => n,Goto(CallStatus-${DIALSTATUS},1)
    exten => CallStatus-NOANSWER,1,Verbose(1,Call Status = No Answer)
        same => n,Hangup()

     exten => CallStatus-BUSY,1,Verbose(1,Call Status = Busy)
        same => n,Hangup()

     exten => _CallStatus-.,1,Verbose(1,Call Status = Unknown)
        same => n,Hangup()

        exten => _X.,1,macro(To-Outbound-Call-Flow)
        exten => h,1,GoTo(macro-To-OBD-Hangup-Call-Flow,h,1)
        exten => s,1,Set(date_time=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
           same => n,Answer()

        exten => h,1,Verbose(1,In Hangup State)

Please help on to minimize used Channels for each call so that I can generate more number of calls from the Server

Note -> Do you know any process for reusing of channels to other extension or vice versa

This will use two, not three, SIP channels and two local channels.

If you remove the “/n” option on the local channel, the local channel should optimise out when the calleee answers.

Dear David,

Yes, you are correct if I use “/n” then it consumes Three Channels 2 -> Local and 1 -> SIP doing this is saving CDR data into Asterisk table
If I removed “/n” from the AMI code first time call consume three channels if user pick or receive call then it is showing only 1 but not saving data into CDR asterisk asterisk
Please let me know the updated status Awaiting for your response

Hello Team,

Please update on my response awaiting for your warm response

There is no team.

You will get responses if people who read this have anything more to contribute. In the previous version of these forums there was an explicit rule not to bump within 24 hours.

You haven’t explained what your real goal is.

Thanks David to wake me up.

Real Goal to optimize channels when Calling via AMI Originate.
In above Scenario Total Three Channels is consumed but if I remove “/n” then only 1 channel is consume on outgoing call but data is not saved in CDR tables
Please suggest

That’s clearly not your real goal. What is your reason for minimising the number of channels used?

Dear David,

I have only 100 SIP Channels , if each call would take 3 channels then only 33 concurrent outgoing call will take place, if I do some optimization then it will increase from 33 to 60 -70 concurrent calls

Your 100 “SIP channels” are not Asterisk channels, they are more of a marketing concept by your service provider.

Asterisk will only ever use two of them for your originate, although it may take some time before they are fully released at the end of a call, because of how SIP works.

The Asterisk local channels are completely invisible to the service provider.

Thanks David.

I believe all channels is of asterisk only Provider take care only for Outgoing calls

Thanks alot for your support.

Can you help me on another Problem.
Do we have such command in asterisk console where we can get AMI Originate call status either disconnect or connect in Real Time

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