Dynamic Routing never routes call

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic Routing never routes call

Mark Farmer
Hello all

Very new OpenSIPS user trying to build my first real server.

Using debug logging I can see that my alias/dialplan operations seem to be working but when it reaches the do_routing the call never actually gets routed.

I've been trying to get this working for nearly 2 weeks now and I'm at a loss now. Please can someone help me?

From my script:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Oddly, I never get the no rules log entry but it drops out of here & into the else if below which forces proxy auth. 

My DB:

dr gateways
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
| id | gwid         | type | address             | strip | pri_prefix | attrs        | probe_mode | state | socket | description |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
|  2 | BT_SDIN_BCTE |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_BCTE |          2 |     0 |        | Inbound     |
|  3 | BT_SDIN_GDH  |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_GDH  |          2 |     0 |        | Inbound     |
|  1 | BT_SDIN_LFH  |    1 | sip:xxx.xxx.xxx.xxx |     0 |            | BT_SDIN_LFH  |          2 |     0 |        | Inbound     |
|  4 | BT_SDIN_SEH  |    1 | sip:xxx.xxx.xxx.xxx  |     0 |            | BT_SDIN_SEH  |          2 |     0 |        | Inbound     |
|  5 | testpbx1     |    1 | sip:10.98.0.11      |     2 | 0          | testpbx1     |          2 |     0 |        | Inbound     |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
dr groups
+----+--------------+----------------------------+---------+-------------+
| id | username     | domain                     | groupid | description |
+----+--------------+----------------------------+---------+-------------+
|  7 | 441423369031 | 10.98.0.11                 |       1 |             |
|  6 | 441423369031 | my.domain |       2 |             |
+----+--------------+----------------------------+---------+-------------+
dr carriers
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
| id | carrierid | gwlist                                           | flags | state | attrs | description |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
|  1 | BT        | BT_SDIN_BCTE,BT_SDIN_GDH,BT_SDIN_LFH,BT_SDIN_SEH |     0 |     0 |       | BT SDIN     |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
dr rules
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+



--
Mark Farmer
[hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Routing never routes call

Jim DeVito
Are you missing the actual relay part? I'm pretty sure do_routing just loads routing info from the database but you sill need to call the actual relay. Put a t_relay() after the IF statement and see what happens. Also look at the docs regarding capturing and displaying the return code from do_routing.



On Fri, Jan 25, 2019 at 9:52 AM Mark Farmer <[hidden email]> wrote:
Hello all

Very new OpenSIPS user trying to build my first real server.

Using debug logging I can see that my alias/dialplan operations seem to be working but when it reaches the do_routing the call never actually gets routed.

I've been trying to get this working for nearly 2 weeks now and I'm at a loss now. Please can someone help me?

From my script:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Oddly, I never get the no rules log entry but it drops out of here & into the else if below which forces proxy auth. 

My DB:

dr gateways
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
| id | gwid         | type | address             | strip | pri_prefix | attrs        | probe_mode | state | socket | description |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
|  2 | BT_SDIN_BCTE |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_BCTE |          2 |     0 |        | Inbound     |
|  3 | BT_SDIN_GDH  |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_GDH  |          2 |     0 |        | Inbound     |
|  1 | BT_SDIN_LFH  |    1 | sip:xxx.xxx.xxx.xxx |     0 |            | BT_SDIN_LFH  |          2 |     0 |        | Inbound     |
|  4 | BT_SDIN_SEH  |    1 | sip:xxx.xxx.xxx.xxx  |     0 |            | BT_SDIN_SEH  |          2 |     0 |        | Inbound     |
|  5 | testpbx1     |    1 | sip:10.98.0.11      |     2 | 0          | testpbx1     |          2 |     0 |        | Inbound     |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
dr groups
+----+--------------+----------------------------+---------+-------------+
| id | username     | domain                     | groupid | description |
+----+--------------+----------------------------+---------+-------------+
|  7 | 441423369031 | 10.98.0.11                 |       1 |             |
|  6 | 441423369031 | my.domain |       2 |             |
+----+--------------+----------------------------+---------+-------------+
dr carriers
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
| id | carrierid | gwlist                                           | flags | state | attrs | description |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
|  1 | BT        | BT_SDIN_BCTE,BT_SDIN_GDH,BT_SDIN_LFH,BT_SDIN_SEH |     0 |     0 |       | BT SDIN     |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
dr rules
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+



--
Mark Farmer
[hidden email]
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
-------------
Jim DeVito
Mobile 216.507.9497

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Routing never routes call

Mark Farmer
In reply to this post by Mark Farmer
A little more info from the logs:

DBG:db_mysql:db_mysql_str2val: converting STRING [+441423369031]
DBG:db_mysql:db_mysql_str2val: converting STRING [10.98.0.11]
DBG:alias_db:alias_db_query: new URI [0] is [[hidden email]]
DBG:core:db_free_columns: freeing result columns at 0x7f5cf8f9b720
DBG:core:db_free_rows: freeing 1 rows
DBG:core:db_free_row: freeing row values at 0x7f5cf8f9b780
DBG:core:db_free_rows: freeing rows at 0x7f5cf8f9b770
DBG:core:db_free_result: freeing result set at 0x7f5cf8f9b6d8
DBG:dialplan:dp_translate_f: dpid is 1 partition is default
DBG:dialplan:dp_get_svalue: searching 15
DBG:dialplan:dp_translate_f: input is +441423369031
DBG:dialplan:dp_translate_f: Checking with dpid 1
DBG:dialplan:translate: Regex operator testing. Got result: -1
DBG:dialplan:test_match: test_match:[0] +441423369031
DBG:dialplan:translate: Regex operator testing. Got result: 0
DBG:dialplan:translate: Found a matching rule 0x7f5cf7233908: pr 1, match_exp \+[1-9][0-9]+$
DBG:dialplan:test_match: test_match:[0] +441423369031
DBG:dialplan:test_match: test_match:[1] 441423369031
DBG:dialplan:dp_translate_f: input +441423369031 with dpid 1 => output 441423369031
DBG:drouting:do_routing_1: matching prefix with strict len
DBG:drouting:do_routing: using dr group 1, rule_idx 0, username 441423369031
DBG:drouting:internal_check_rt: found rgid 1 (rule list 0x7f5cf72360a8)
DBG:drouting:push_gw_for_usage: adding gw [testpbx1] as "[hidden email]" in order 0
DBG:drouting:push_gw_for_usage: setting GW id [testpbx1] as avp
DBG:drouting:push_gw_for_usage: setting GW attr [testpbx1] as avp
DBG:drouting:do_routing: setting RULE attr [rule_441423369031]
DBG:core:parse_headers: flags=10000
DBG:auth:pre_auth: credentials with given realm not found
Jan 25 15:00:39 tsip3 /usr/local/sbin/opensips[12173]: ----- gw attr is <null>
Jan 25 15:00:39 tsip3 /usr/local/sbin/opensips[12173]: ----- ruri is [hidden email]
Jan 25 15:00:39 tsip3 /usr/local/sbin/opensips[12173]: proxy: MF - Fell into proxy auth



On Fri, 25 Jan 2019 at 14:51, Mark Farmer <[hidden email]> wrote:
Hello all

Very new OpenSIPS user trying to build my first real server.

Using debug logging I can see that my alias/dialplan operations seem to be working but when it reaches the do_routing the call never actually gets routed.

I've been trying to get this working for nearly 2 weeks now and I'm at a loss now. Please can someone help me?

From my script:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Oddly, I never get the no rules log entry but it drops out of here & into the else if below which forces proxy auth. 

My DB:

dr gateways
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
| id | gwid         | type | address             | strip | pri_prefix | attrs        | probe_mode | state | socket | description |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
|  2 | BT_SDIN_BCTE |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_BCTE |          2 |     0 |        | Inbound     |
|  3 | BT_SDIN_GDH  |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_GDH  |          2 |     0 |        | Inbound     |
|  1 | BT_SDIN_LFH  |    1 | sip:xxx.xxx.xxx.xxx |     0 |            | BT_SDIN_LFH  |          2 |     0 |        | Inbound     |
|  4 | BT_SDIN_SEH  |    1 | sip:xxx.xxx.xxx.xxx  |     0 |            | BT_SDIN_SEH  |          2 |     0 |        | Inbound     |
|  5 | testpbx1     |    1 | sip:10.98.0.11      |     2 | 0          | testpbx1     |          2 |     0 |        | Inbound     |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
dr groups
+----+--------------+----------------------------+---------+-------------+
| id | username     | domain                     | groupid | description |
+----+--------------+----------------------------+---------+-------------+
|  7 | 441423369031 | 10.98.0.11                 |       1 |             |
|  6 | 441423369031 | my.domain |       2 |             |
+----+--------------+----------------------------+---------+-------------+
dr carriers
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
| id | carrierid | gwlist                                           | flags | state | attrs | description |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
|  1 | BT        | BT_SDIN_BCTE,BT_SDIN_GDH,BT_SDIN_LFH,BT_SDIN_SEH |     0 |     0 |       | BT SDIN     |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
dr rules
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+



--
Mark Farmer
[hidden email]


--
Mark Farmer
[hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Routing never routes call

Mark Farmer
In reply to this post by Jim DeVito
Thanks Jim.

I now have:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          t_relay();
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Sadly no change.

I'll head over to the docs again now.



On Fri, 25 Jan 2019 at 15:08, Jim DeVito <[hidden email]> wrote:
Are you missing the actual relay part? I'm pretty sure do_routing just loads routing info from the database but you sill need to call the actual relay. Put a t_relay() after the IF statement and see what happens. Also look at the docs regarding capturing and displaying the return code from do_routing.



On Fri, Jan 25, 2019 at 9:52 AM Mark Farmer <[hidden email]> wrote:
Hello all

Very new OpenSIPS user trying to build my first real server.

Using debug logging I can see that my alias/dialplan operations seem to be working but when it reaches the do_routing the call never actually gets routed.

I've been trying to get this working for nearly 2 weeks now and I'm at a loss now. Please can someone help me?

From my script:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Oddly, I never get the no rules log entry but it drops out of here & into the else if below which forces proxy auth. 

My DB:

dr gateways
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
| id | gwid         | type | address             | strip | pri_prefix | attrs        | probe_mode | state | socket | description |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
|  2 | BT_SDIN_BCTE |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_BCTE |          2 |     0 |        | Inbound     |
|  3 | BT_SDIN_GDH  |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_GDH  |          2 |     0 |        | Inbound     |
|  1 | BT_SDIN_LFH  |    1 | sip:xxx.xxx.xxx.xxx |     0 |            | BT_SDIN_LFH  |          2 |     0 |        | Inbound     |
|  4 | BT_SDIN_SEH  |    1 | sip:xxx.xxx.xxx.xxx  |     0 |            | BT_SDIN_SEH  |          2 |     0 |        | Inbound     |
|  5 | testpbx1     |    1 | sip:10.98.0.11      |     2 | 0          | testpbx1     |          2 |     0 |        | Inbound     |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
dr groups
+----+--------------+----------------------------+---------+-------------+
| id | username     | domain                     | groupid | description |
+----+--------------+----------------------------+---------+-------------+
|  7 | 441423369031 | 10.98.0.11                 |       1 |             |
|  6 | 441423369031 | my.domain |       2 |             |
+----+--------------+----------------------------+---------+-------------+
dr carriers
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
| id | carrierid | gwlist                                           | flags | state | attrs | description |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
|  1 | BT        | BT_SDIN_BCTE,BT_SDIN_GDH,BT_SDIN_LFH,BT_SDIN_SEH |     0 |     0 |       | BT SDIN     |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
dr rules
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+



--
Mark Farmer
[hidden email]
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
-------------
Jim DeVito
Mobile 216.507.9497
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
Mark Farmer
[hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Routing never routes call

Jennifer Hashimoto
You are only going into the block that you put the relay in if your do_routing fails.

pay attention to the ! which means NOT

---------------------------------------------------
Jennifer Akemi Hashimoto
Caztel Communications
[hidden email]
905-836-5445 

On Jan 25, 2019, at 10:24 AM, Mark Farmer <[hidden email]> wrote:

Thanks Jim.

I now have:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          t_relay();
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Sadly no change.

I'll head over to the docs again now.



On Fri, 25 Jan 2019 at 15:08, Jim DeVito <[hidden email]> wrote:
Are you missing the actual relay part? I'm pretty sure do_routing just loads routing info from the database but you sill need to call the actual relay. Put a t_relay() after the IF statement and see what happens. Also look at the docs regarding capturing and displaying the return code from do_routing.



On Fri, Jan 25, 2019 at 9:52 AM Mark Farmer <[hidden email]> wrote:
Hello all

Very new OpenSIPS user trying to build my first real server.

Using debug logging I can see that my alias/dialplan operations seem to be working but when it reaches the do_routing the call never actually gets routed.

I've been trying to get this working for nearly 2 weeks now and I'm at a loss now. Please can someone help me?

From my script:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Oddly, I never get the no rules log entry but it drops out of here & into the else if below which forces proxy auth. 

My DB:

dr gateways
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
| id | gwid         | type | address             | strip | pri_prefix | attrs        | probe_mode | state | socket | description |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
|  2 | BT_SDIN_BCTE |    1 | <a href="sip:xxx.xxx.xxx.xxx" class="">sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_BCTE |          2 |     0 |        | Inbound     |
|  3 | BT_SDIN_GDH  |    1 | <a href="sip:xxx.xxx.xxx.xxx" class="">sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_GDH  |          2 |     0 |        | Inbound     |
|  1 | BT_SDIN_LFH  |    1 | <a href="sip:xxx.xxx.xxx.xxx" class="">sip:xxx.xxx.xxx.xxx |     0 |            | BT_SDIN_LFH  |          2 |     0 |        | Inbound     |
|  4 | BT_SDIN_SEH  |    1 | <a href="sip:xxx.xxx.xxx.xxx" class="">sip:xxx.xxx.xxx.xxx  |     0 |            | BT_SDIN_SEH  |          2 |     0 |        | Inbound     |
|  5 | testpbx1     |    1 | <a href="sip:10.98.0.11" class="">sip:10.98.0.11      |     2 | 0          | testpbx1     |          2 |     0 |        | Inbound     |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
dr groups
+----+--------------+----------------------------+---------+-------------+
| id | username     | domain                     | groupid | description |
+----+--------------+----------------------------+---------+-------------+
|  7 | 441423369031 | 10.98.0.11                 |       1 |             |
|  6 | 441423369031 | my.domain |       2 |             |
+----+--------------+----------------------------+---------+-------------+
dr carriers
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
| id | carrierid | gwlist                                           | flags | state | attrs | description |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
|  1 | BT        | BT_SDIN_BCTE,BT_SDIN_GDH,BT_SDIN_LFH,BT_SDIN_SEH |     0 |     0 |       | BT SDIN     |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
dr rules
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+



--
Mark Farmer
[hidden email]
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
-------------
Jim DeVito
Mobile 216.507.9497
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
Mark Farmer
[hidden email]
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Routing never routes call

Jon Abrams
In reply to this post by Mark Farmer
You have the t_relay() in the do_routing() failure code section. Move it afterwards:


        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
        
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;
         }

         t_relay();

- Jon

On Fri, Jan 25, 2019 at 9:27 AM Mark Farmer <[hidden email]> wrote:
Thanks Jim.

I now have:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          t_relay();
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Sadly no change.

I'll head over to the docs again now.



On Fri, 25 Jan 2019 at 15:08, Jim DeVito <[hidden email]> wrote:
Are you missing the actual relay part? I'm pretty sure do_routing just loads routing info from the database but you sill need to call the actual relay. Put a t_relay() after the IF statement and see what happens. Also look at the docs regarding capturing and displaying the return code from do_routing.



On Fri, Jan 25, 2019 at 9:52 AM Mark Farmer <[hidden email]> wrote:
Hello all

Very new OpenSIPS user trying to build my first real server.

Using debug logging I can see that my alias/dialplan operations seem to be working but when it reaches the do_routing the call never actually gets routed.

I've been trying to get this working for nearly 2 weeks now and I'm at a loss now. Please can someone help me?

From my script:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Oddly, I never get the no rules log entry but it drops out of here & into the else if below which forces proxy auth. 

My DB:

dr gateways
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
| id | gwid         | type | address             | strip | pri_prefix | attrs        | probe_mode | state | socket | description |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
|  2 | BT_SDIN_BCTE |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_BCTE |          2 |     0 |        | Inbound     |
|  3 | BT_SDIN_GDH  |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_GDH  |          2 |     0 |        | Inbound     |
|  1 | BT_SDIN_LFH  |    1 | sip:xxx.xxx.xxx.xxx |     0 |            | BT_SDIN_LFH  |          2 |     0 |        | Inbound     |
|  4 | BT_SDIN_SEH  |    1 | sip:xxx.xxx.xxx.xxx  |     0 |            | BT_SDIN_SEH  |          2 |     0 |        | Inbound     |
|  5 | testpbx1     |    1 | sip:10.98.0.11      |     2 | 0          | testpbx1     |          2 |     0 |        | Inbound     |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
dr groups
+----+--------------+----------------------------+---------+-------------+
| id | username     | domain                     | groupid | description |
+----+--------------+----------------------------+---------+-------------+
|  7 | 441423369031 | 10.98.0.11                 |       1 |             |
|  6 | 441423369031 | my.domain |       2 |             |
+----+--------------+----------------------------+---------+-------------+
dr carriers
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
| id | carrierid | gwlist                                           | flags | state | attrs | description |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
|  1 | BT        | BT_SDIN_BCTE,BT_SDIN_GDH,BT_SDIN_LFH,BT_SDIN_SEH |     0 |     0 |       | BT SDIN     |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
dr rules
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+



--
Mark Farmer
[hidden email]
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
-------------
Jim DeVito
Mobile 216.507.9497
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
Mark Farmer
[hidden email]
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Routing never routes call

Mark Farmer
OK, that's changed something!

I'm now getting 'do_routing: No rules matching the URI' in my log - so I guess I need to review the rules.

Many thanks for the help so far!!



On Fri, 25 Jan 2019 at 15:35, Jon Abrams <[hidden email]> wrote:
You have the t_relay() in the do_routing() failure code section. Move it afterwards:


        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
        
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;
         }

         t_relay();

- Jon

On Fri, Jan 25, 2019 at 9:27 AM Mark Farmer <[hidden email]> wrote:
Thanks Jim.

I now have:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          t_relay();
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Sadly no change.

I'll head over to the docs again now.



On Fri, 25 Jan 2019 at 15:08, Jim DeVito <[hidden email]> wrote:
Are you missing the actual relay part? I'm pretty sure do_routing just loads routing info from the database but you sill need to call the actual relay. Put a t_relay() after the IF statement and see what happens. Also look at the docs regarding capturing and displaying the return code from do_routing.



On Fri, Jan 25, 2019 at 9:52 AM Mark Farmer <[hidden email]> wrote:
Hello all

Very new OpenSIPS user trying to build my first real server.

Using debug logging I can see that my alias/dialplan operations seem to be working but when it reaches the do_routing the call never actually gets routed.

I've been trying to get this working for nearly 2 weeks now and I'm at a loss now. Please can someone help me?

From my script:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Oddly, I never get the no rules log entry but it drops out of here & into the else if below which forces proxy auth. 

My DB:

dr gateways
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
| id | gwid         | type | address             | strip | pri_prefix | attrs        | probe_mode | state | socket | description |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
|  2 | BT_SDIN_BCTE |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_BCTE |          2 |     0 |        | Inbound     |
|  3 | BT_SDIN_GDH  |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_GDH  |          2 |     0 |        | Inbound     |
|  1 | BT_SDIN_LFH  |    1 | sip:xxx.xxx.xxx.xxx |     0 |            | BT_SDIN_LFH  |          2 |     0 |        | Inbound     |
|  4 | BT_SDIN_SEH  |    1 | sip:xxx.xxx.xxx.xxx  |     0 |            | BT_SDIN_SEH  |          2 |     0 |        | Inbound     |
|  5 | testpbx1     |    1 | sip:10.98.0.11      |     2 | 0          | testpbx1     |          2 |     0 |        | Inbound     |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
dr groups
+----+--------------+----------------------------+---------+-------------+
| id | username     | domain                     | groupid | description |
+----+--------------+----------------------------+---------+-------------+
|  7 | 441423369031 | 10.98.0.11                 |       1 |             |
|  6 | 441423369031 | my.domain |       2 |             |
+----+--------------+----------------------------+---------+-------------+
dr carriers
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
| id | carrierid | gwlist                                           | flags | state | attrs | description |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
|  1 | BT        | BT_SDIN_BCTE,BT_SDIN_GDH,BT_SDIN_LFH,BT_SDIN_SEH |     0 |     0 |       | BT SDIN     |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
dr rules
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+



--
Mark Farmer
[hidden email]
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
-------------
Jim DeVito
Mobile 216.507.9497
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
Mark Farmer
[hidden email]
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


--
Mark Farmer
[hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Routing never routes call

Liviu Chircu
In reply to this post by Mark Farmer

Hi, Mark!

Notice this log:

Jan 25 15:00:39 tsip3 /usr/local/sbin/opensips[12173]: ----- ruri is [hidden email]

... and your drouting rule:

+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |

Although OpenSIPS does a lot of things behind the curtain, detecting and auto-stripping UK prefixes is a job that it does not.

Here's an additional tip: to quickly test your prefix matching using a modern OpenSIPS, you can do:

opensipsctl fifo dr_number_routing 1 441423369031

In your case, it would have outputted nothing, meaning: "no match found"

Cheers,
Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com
On 25.01.2019 17:06, Mark Farmer wrote:
A little more info from the logs:

DBG:db_mysql:db_mysql_str2val: converting STRING [+441423369031]
DBG:db_mysql:db_mysql_str2val: converting STRING [10.98.0.11]
DBG:alias_db:alias_db_query: new URI [0] is [[hidden email]]
DBG:core:db_free_columns: freeing result columns at 0x7f5cf8f9b720
DBG:core:db_free_rows: freeing 1 rows
DBG:core:db_free_row: freeing row values at 0x7f5cf8f9b780
DBG:core:db_free_rows: freeing rows at 0x7f5cf8f9b770
DBG:core:db_free_result: freeing result set at 0x7f5cf8f9b6d8
DBG:dialplan:dp_translate_f: dpid is 1 partition is default
DBG:dialplan:dp_get_svalue: searching 15
DBG:dialplan:dp_translate_f: input is +441423369031
DBG:dialplan:dp_translate_f: Checking with dpid 1
DBG:dialplan:translate: Regex operator testing. Got result: -1
DBG:dialplan:test_match: test_match:[0] +441423369031
DBG:dialplan:translate: Regex operator testing. Got result: 0
DBG:dialplan:translate: Found a matching rule 0x7f5cf7233908: pr 1, match_exp \+[1-9][0-9]+$
DBG:dialplan:test_match: test_match:[0] +441423369031
DBG:dialplan:test_match: test_match:[1] 441423369031
DBG:dialplan:dp_translate_f: input +441423369031 with dpid 1 => output 441423369031
DBG:drouting:do_routing_1: matching prefix with strict len
DBG:drouting:do_routing: using dr group 1, rule_idx 0, username 441423369031
DBG:drouting:internal_check_rt: found rgid 1 (rule list 0x7f5cf72360a8)
DBG:drouting:push_gw_for_usage: adding gw [testpbx1] as "[hidden email]" in order 0
DBG:drouting:push_gw_for_usage: setting GW id [testpbx1] as avp
DBG:drouting:push_gw_for_usage: setting GW attr [testpbx1] as avp
DBG:drouting:do_routing: setting RULE attr [rule_441423369031]
DBG:core:parse_headers: flags=10000
DBG:auth:pre_auth: credentials with given realm not found
Jan 25 15:00:39 tsip3 /usr/local/sbin/opensips[12173]: ----- gw attr is <null>
Jan 25 15:00:39 tsip3 /usr/local/sbin/opensips[12173]: ----- ruri is [hidden email]
Jan 25 15:00:39 tsip3 /usr/local/sbin/opensips[12173]: proxy: MF - Fell into proxy auth



On Fri, 25 Jan 2019 at 14:51, Mark Farmer <[hidden email]> wrote:
Hello all

Very new OpenSIPS user trying to build my first real server.

Using debug logging I can see that my alias/dialplan operations seem to be working but when it reaches the do_routing the call never actually gets routed.

I've been trying to get this working for nearly 2 weeks now and I'm at a loss now. Please can someone help me?

From my script:

        $avp(gw_whitelist) = "testpbx1";
        if ( !do_routing("1","L","$avp(gw_whitelist)","$avp(rules_attributes)","$avp(gw_attributes)")) {
          send_reply("404","DID not found");
          xlog("do_routing: No rules matching the URI\n");
          exit;

Oddly, I never get the no rules log entry but it drops out of here & into the else if below which forces proxy auth. 

My DB:

dr gateways
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
| id | gwid         | type | address             | strip | pri_prefix | attrs        | probe_mode | state | socket | description |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
|  2 | BT_SDIN_BCTE |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_BCTE |          2 |     0 |        | Inbound     |
|  3 | BT_SDIN_GDH  |    1 | sip:xxx.xxx.xxx.xxx   |     0 |            | BT_SDIN_GDH  |          2 |     0 |        | Inbound     |
|  1 | BT_SDIN_LFH  |    1 | sip:xxx.xxx.xxx.xxx |     0 |            | BT_SDIN_LFH  |          2 |     0 |        | Inbound     |
|  4 | BT_SDIN_SEH  |    1 | sip:xxx.xxx.xxx.xxx  |     0 |            | BT_SDIN_SEH  |          2 |     0 |        | Inbound     |
|  5 | testpbx1     |    1 | sip:10.98.0.11      |     2 | 0          | testpbx1     |          2 |     0 |        | Inbound     |
+----+--------------+------+---------------------+-------+------------+--------------+------------+-------+--------+-------------+
dr groups
+----+--------------+----------------------------+---------+-------------+
| id | username     | domain                     | groupid | description |
+----+--------------+----------------------------+---------+-------------+
|  7 | 441423369031 | 10.98.0.11                 |       1 |             |
|  6 | 441423369031 | my.domain |       2 |             |
+----+--------------+----------------------------+---------+-------------+
dr carriers
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
| id | carrierid | gwlist                                           | flags | state | attrs | description |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
|  1 | BT        | BT_SDIN_BCTE,BT_SDIN_GDH,BT_SDIN_LFH,BT_SDIN_SEH |     0 |     0 |       | BT SDIN     |
+----+-----------+--------------------------------------------------+-------+-------+-------+-------------+
dr rules
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
| ruleid | groupid | prefix       | timerec | priority | routeid | gwlist   | attrs             | description      |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+
|     13 | 1       | 441423369031 |         |        0 |         | testpbx1 | rule_441423369031 | Send to testpbx1 |
+--------+---------+--------------+---------+----------+---------+----------+-------------------+------------------+



--
Mark Farmer
[hidden email]


--
Mark Farmer
[hidden email]

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Routing never routes call

John Quick
In reply to this post by Mark Farmer
Hi Mark,

Liviu made a mistake in his last response to you. He picked out the debug at
the end of the drouting process, not the beginning. Perhaps he had the
screen upside down.

From the debug it is clear that do_routing behaved correctly and has worked.
So the problem is either that you have misunderstood what the do_routing()
function is meant to do OR you have a mistake in the code in your script
just after the snippet that you posted to the forum.

do_routing() will only alter the R-URI. It does not then send the request to
the destination and exit. You must do this explicitly, for example:
t_relay()
exit

As a general point for anyone using OpenSIPS, it is worth noting that just
about every function will return.
The only exception I can think of right now is t_check_trans() and even that
will sometimes return - it depends on specific conditions.
If you want the main route in your script to stop executing after a function
has been called, you need to insert an exit statement.
Also note that each type of route has a default behaviour on exit as
described in the documentation under the heading "Types of routes"

John Quick
Smartvox Limited
Web: www.smartvox.co.uk



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users