[OpenSIPS-Users] Dispatcher stickyness for external inbound calls

David Villasmil david.villasmil.work at gmail.com
Thu Dec 5 12:02:46 EST 2019


Hello

Dialplan is perfect for this.
I did this on kamailio, but it's probably doable porting it.

It would be something like:

modparam("dialplan", "db_url", DBURL)

...

route[DISPATCH] {
...
# Get the attrs field for the matching domain, will store the result in
$var(dispatcher_id)
    dp_translate( "1", "$ru", "$var(dispatcher_id)" )

# Select the group of fs nodes that we want this call to be sent to.
    if(!ds_select_dst("$var(dispatcher_id)", "4"))
    {
        xlog("[DISPATCH]: ds_select_dst FAILED!'\n");
        send_reply("404", "No destination");
        exit;
    }

    xlog("L_DBG", "[DISPATCH]: going to <$ru> via <$du>\n");
    t_on_failure("RTF_DISPATCH");
    route(RELAY);
}


Your dialplan table would look like this:

+----+------+-----+----------+---------------------------+-----------+-----------+----------+-------+
| id | dpid | pr  | match_op | match_exp                 | match_len |
subst_exp | repl_exp | attrs |
+----+------+-----+----------+---------------------------+-----------+-----------+----------+-------+
| 37 |    1 | 100 |        1 | .*domain1*                |         0 |
      |          | 10    |
| 55 |    1 | 100 |        1 | .*domain2*                |         0 |
      |          | 30    |
| 56 |    1 | 100 |        1 | .*domain3*                |         0 |
      |          | 30    |

and your dispatcher would look like you want to distribute your traffic:

+------+-------+-------------------------+-------+----------+----------------------------------+------------------+
| id   | setid | destination             | flags | priority | attrs
                   | description      |
+------+-------+-------------------------+-------+----------+----------------------------------+------------------+
| 3097 |    10 | sip:1.2.3.1:5080        |     0 |       10 |       |
server-01        |
| 3098 |    10 | sip:1.2.3.2:5080        |     0 |       10 |       |
server-02        |
| 3110 |    20 | sip:1.2.3.1:5080        |     0 |       10 |       |
server-01        |
| 3109 |    20 | sip:1.2.3.2:5080        |     0 |       10 |       |
server-02        |
| 3108 |    30 | sip:1.2.3.3:5080        |     0 |       10 |       |
server-03        |

I hope that helps!

David

On Thu, 5 Dec 2019 at 15:01, Matthias Kneer via Users <
users at lists.opensips.org> wrote:

> Hi list,
>
> I'm currently building a HA setup with 2 openSIPS 2.4 instances which do
> share a floating IP through keepalived. They are working as 1:1
> mid_registrar, gateway to the PSTN and dispatcher for multiple FreeSWITCH
> instances. Those FreeSWITCH instances hold all accounts, domains and media
> services, they also do the RTP part.
>
> Since we are hosting multiple customers on the same FreeSWITCH instances,
> sperated through domains, we'd like to ensure that all registrations of a
> domain stay on the same FreeSWITCH as long this instance is reachable. We
> want this to ensure that conferences, call pickups and so on work reliable.
> It's not very important for us to distribute the load evenly since we have
> no high call / conference volume, the goal is more to have the setup as
> available as possible with some sort of loadbalancing and without having to
> take manual action if one of the FreeSWITCHes dies.
>
> To achieve this, our idea was to set *modparam("dispatcher", "hash_pvar",
> "$fd")* to use the from domain as source for hashing and call *ds_select_dst
> *with the alg "7":
>
> if (!ds_select_dst("2", "7"))
> {
>   xlog("L_ERR", "$ci|end|no servers avaliable");
>   sl_send_reply("480", "Temporarily Unavailable");
>   exit;
> }
>
> This approach works fine as long as we use it for internal calls since
> those have the from / to domain part properly set. If a call arrives from
> the PSTN openSIPS has no knowledge about the relation of the external
> numbers and internal numbers / domains. Is there a smart way to properly
> route those external calls to the correct FreeSWITCH wihtout having
> openSIPS to access the FreeSWITCH database / duplicating the data into the
> openSIPS database or to run FreeSWITCH in active/standby mode?
>
> Best regards,
> Matthias
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20191205/00010ad8/attachment.html>


More information about the Users mailing list