OpenSIPS / opensips

OpenSIPS is a GPL implementation of a multi-functionality SIP Server that targets to deliver a high-level technical solution (performance, security and quality) to be used in professional SIP server platforms.
https://opensips.org
Other
1.28k stars 581 forks source link

CGRates module not working as expected. #1122

Closed Digital-Daz closed 7 years ago

Digital-Daz commented 7 years ago

With the following calls still go through despite errors from cgrates:

T 127.0.0.1:47971 -> 127.0.0.1:2012 [AP]
{ "method": "SMGenericV1.GetMaxUsage", "params": [ { "Destination": "441617102180", "RequestType": "*prepaid", "SetupTime": "1494587835", "Category": "call_standard1", "OriginID": "2551522646@192.168.1.70", "Account": "9470898910", "Tenant": "rater.sip247.com" } ] }
##
T 127.0.0.1:2012 -> 127.0.0.1:47971 [AP]
{"id":null,"result":null,"error":"SERVER_ERROR: RATING_PLAN_NOT_FOUND"}

At this point it looks like $rc = 0 and $cgrret = null

route [resume_cgr_auth] {
        if (($rc < 0)) {
                xlog("Call not authorized: rc = $retcode code=$cgrret!\n");
                send_reply("403", "Forbidden");
                exit;
        }
xlog("L_ERR","VARS: cgrret is $cgrret, rc is $rc\n");
    #cgrates_acc("cdr|missed", "$fU", "$rU");
    cgrates_acc("cdr|missed", "$(fU{s.substr,0,10})", "$rU");
        if (is_method("INVITE|UPDATE")) {

                if (isflagset(NAT)) {
                        rtpengine_manage();
                }

                t_on_branch("per_branch_ops");
                t_on_reply("handle_nat");
                t_on_failure("missed_call");
        }

        if (isflagset(NAT)) {
                add_rr_param(";nat=yes");
                }

        if (!t_relay()) {
                send_reply("500","Internal Error");
        };
        exit;
}
razvancrainea commented 7 years ago

Can you provide some debug logs for this kind of call?

Digital-Daz commented 7 years ago

Does this help, I just gave showed this to DanB:

With: if ($rc < 0) { xlog("L_ERR","Call not authorized: rc = $rc code=$cgrret!\n"); send_reply("403", "Forbidden"); exit; } xlog("L_ERR","VARS: cgrret is $cgrret, rc is $rc\n");

So with a call that should be successful:

May 12 11:44:25 11d5168c-7ddf-4493-fd5c-b3580213f4b5 /usr/sbin/opensips[1601]: VARS: cgrret is 10800, rc is 0

T 127.0.0.1:48080 -> 127.0.0.1:2012 [AP] { "method": "SMGenericV1.GetMaxUsage", "params": [ { "Destination": "441617102180", "RequestType": "*prepaid", "SetupTime": "1494589465", "Category": "call_standard", "OriginID": "1447750095@192.168.1.70", "Account": "9470898910", "Tenant": "rater.sip247.com" } ] }

T 127.0.0.1:2012 -> 127.0.0.1:48080 [AP] {"id":null,"result":10800,"error":null}

Now I change cgr_category to make it fail with rating plan not found:

May 12 11:47:11 11d5168c-7ddf-4493-fd5c-b3580213f4b5 CGRateS [19972]: Rating plan not found for destination 441617102180 and account: rater.sip247.com:9470898910, subject: *out:rater.sip247.com:call_standard1:9470898910 May 12 11:47:11 11d5168c-7ddf-4493-fd5c-b3580213f4b5 CGRateS [19972]: Error getting cost for account key : RATING_PLAN_NOT_FOUND May 12 11:47:11 11d5168c-7ddf-4493-fd5c-b3580213f4b5 /usr/sbin/opensips[1676]: VARS: cgrret is , rc is 0

T 127.0.0.1:48116 -> 127.0.0.1:2012 [AP] { "method": "SMGenericV1.GetMaxUsage", "params": [ { "Destination": "441617102180", "RequestType": "*prepaid", "SetupTime": "1494589631", "Category": "call_standard1", "OriginID": "2069630171@192.168.1.70", "Account": "9470898910", "Tenant": "rater.sip247.com" } ] }

T 127.0.0.1:2012 -> 127.0.0.1:48116 [AP] {"id":null,"result":null,"error":"SERVER_ERROR: RATING_PLAN_NOT_FOUND"}