test cgrates with asterisk failed, please help

43 views
Skip to first unread message

Jason Tips

unread,
Jun 6, 2025, 3:27:54 AMJun 6
to CGRateS
Hello Team,

I am new to cgrates, and the cgrates is too complicate for me to understand.
I studied for a week, but failed to setup billing by *voice type with minutes deduct method.

The billing requirement is simple, i have 10XX extensions, and I want to arrange 10 min for each exten, once the minutes running out, then stop the call.

Here is my dialplan:
root@ec29afbd3af1:/etc/asterisk# cat extensions.conf
[internal]
 exten => _XXXX,1,NoOp()
 same => n,Set(CGRMaxSessionTime=0); use it to disconnect automatically the call if CGRateS is not active
 same => n,Set(LIMIT_WARNING_FILE=/var/lib/asterisk/sounds/en/beep)
 same => n,Set(LIMIT_PLAYAUDIO_CALLER=YES)
 same => n,Set(LIMIT_PLAYAUDIO_CALLEE=YES)
 same => n,DumpChan()
 same => n,Stasis(cgrates_auth,cgr_reqtype=*prepaid,cgr_flags=*accounts+*attributes+*resources+*stats+*routes+*thresholds,cgr_tenant=cgrates.org,cgr_account=${CALLERID(num)},cgr_destination=${EXTEN},cgr_category=call)
 same => n,Set(CHANNEL(hangup_handler_push)=hangUp,hUP,1)
 same => n,Dial(SIP/${EXTEN},30,L(${CGRMaxSessionTime}:10000))
 same => n,Hangup()

[hangUp]
exten => hUP, 1, NoOp(Hang Up)
exten => hUP, 2, GotoIf($["${ANSWEREDTIME}000" != "${CGRMaxSessionTime}"]?exitHangUP:logHangUP)
exten => hUP, 3(logHangUP),Log(WARNING,"Was closed because the max session time")
exten => hUP, 4(exitHangUP),Return()
root@ec29afbd3af1:/etc/asterisk# cat ari.conf
[general]
enabled = yes
allowed_origins = *
channelvars = cgr_reqtype,cgr_flags,cgr_tenant,cgr_account,cgr_destination,cgr_category,CDR(answer),CDR(billsec)

[cgrates]
type = user
read_only = no
password = CGRateS.org

and the csv files attached.

Can anyone help me to understand what is wrong with the csv settings? thanks so much!

Armir Veliaj

unread,
Jun 9, 2025, 10:27:25 AMJun 9
to CGRateS
Hi Jason,

Welcome to CGRateS!

To better understand CGRateS and keep it simple at first, we recommend you check our docs, especially our Tutorial section: https://cgrates.readthedocs.io/en/latest/tutorial.html. To run the calls, you can initially use the predefined tariff plans and samples so you can get more familiar.
After you become more used, you can create your own setup and make changes. In your case, for setting a max call duration, you can change that in the default JSON config of CGRateS in the general config of the SessionS section, where you can set any value as a limit in "default_usage", in your case for *voice calls: https://github.com/cgrates/cgrates/blob/master/config/config_defaults.go#L673

Additionally, we recommend checking via ngrep to see the APIs and events happening while you are running the calls. In case of any issues you may have in the future, you can send those ngrep logs as well so we can assist you better.


Thanks,
Armir
Reply all
Reply to author
Forward
0 new messages