Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Redirect calls, dinamic routing (drouting)

dpinedo
2012-07-11
2013-05-09
  • dpinedo
    dpinedo
    2012-07-11

    I'm trying to redirect calls from softphone clients to a Asterisk server. I'd like to group the calls and redirect them to a specific Asterisk or extension in the Asterisk server. I'd like to add the routes dinamically without to have to restart the opensips server.
    Is the drouting module the best way to do this?
    Exists another module or funcinality to do this?

    Now I'm having a problem:
    I have defined a new route in the opensips.cfg, and I invoque it when there is an INVITE event

    # account only INVITEs
      if (is_method("INVITE")) {
                    setflag(1); # do accounting
                    route(3); # Call dpinedo new dynamic route.
    }

    route {
            if (!do_routing("0")) {
                    send_reply("503", "No Rules matching the URI");
                    exit;
            }
            if (is_method("INVITE")) {
                    t_on_failure("3");
            }
            route(1);
    }

    failure_route {
            if (t_was_cancelled()) {
                    exit;
            }
    }

    And I have added the correspondient entries in the mysql database
    insert into dr_gateways (gwid,type,address,strip,probe_mode,description) VALUES (1,"1","89.1.23.190","0","2","Asterisk Server #1");
    insert into dr_groups (username,domain,groupid,description) VALUES (".*",".*","0","Everyone");
    insert into dr_rules (groupid, prefix,routeid,gwlist,description) VALUES ( "0","","2","1","International Calls");

    89.1.23.190 is my Asterisk server.
    In the Asterisk server there is a dial plan which does a hangup of the call and plays an audio file.
    But when I make a call with a sipphone to the extension of the dial plan in the asterisk (7001) I get the folowing error:
    Sometimes I the call gets stablished but I the errors always appears.
    The warnings reffers to the definition of the routes  (autogenerated in the insalation process) and to the route added by me.
    I don't understand the errors in the tm module.
    There is any good tutorial about this themes?

    Jul 11 17:25:26 localhost /usr/sbin/opensips: CRITICAL:core:eval_expr: too many expressions (101)
    Jul 11 17:25:26 localhost /usr/sbin/opensips: WARNING:core:do_action: error in expression (l=387)
    Jul 11 17:25:26 localhost /usr/sbin/opensips: CRITICAL:core:eval_expr: too many expressions (101)
    Jul 11 17:25:26 localhost /usr/sbin/opensips: WARNING:core:do_action: error in expression (l=390)
    Jul 11 17:25:26 localhost /usr/sbin/opensips: CRITICAL:core:eval_expr: too many expressions (101)
    Jul 11 17:25:26 localhost /usr/sbin/opensips: WARNING:core:do_action: error in expression (l=350)
    Jul 11 17:25:26 localhost /usr/sbin/opensips: CRITICAL:core:eval_expr: too many expressions (101)
    Jul 11 17:25:26 localhost /usr/sbin/opensips: WARNING:core:do_action: error in expression (l=352)
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: new branch at sip:7001@89.1.23.190
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 500 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 500 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 500 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 500 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 500 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 500 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ACC: transaction answered: timestamp=1342020326;method=INVITE;from_tag=938c8855;to_tag=as322e048b;call_id=N2MyZjQ1ZTUwZGViZDA0MjRlMWY4MjgyOTNjMjdlYmM.;code=200;reason=OK
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:add_uac: maximum number of branches exceeded
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:t_forward_nonack: failure to add branches
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:w_t_relay: t_forward_nonack failed
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:tm:_reply_light: failed to generate 500 reply when a final 200 was sent out
    Jul 11 17:25:26 localhost /usr/sbin/opensips: ERROR:signaling:sig_send_reply_mod: failed to send reply with tm module
    Jul 11 17:25:27 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:28 localhost /usr/sbin/opensips: incoming reply
    Jul 11 17:25:30 localhost /usr/sbin/opensips: incoming reply

     
  • In dr_rules table, set NULL for "routeid"

    Regards,
    bogdan

     
  • dpinedo
    dpinedo
    2012-07-12

    indeed!!
    Thankyou