[SR-Users] Kamailio with dispatcher and asterisks real time

PICCORO McKAY Lenz mckaygerhard at gmail.com
Sun May 3 21:15:44 CEST 2020


the problem with Aserisk realtime and the kamailio dispatcher integration,
are the string ip comparitions. The guide points out two important routines,
which are FROMASTERISK and TOASTERISK, in these it is verified if the
request acts from asterisk, or goes to asterisk.
But are another routine that are also important, es la REGFWD

I was able to adjust these routines (mediocre, because I only check
if it comes from one of the asterisks on the list and not the one in question),
but in the REGFWD rules, the code are bit confusing..

i made this:

1) follow the normal guideliness ... enable the module by addiding the
loadmodule "dispatcher.so" and later specify source list/db by
modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
etc etc ..  and adde a rule "route[DISPATCH]" of course. ..
2) later i sustitute the rutines of FROMASTERISK and TOASTERISK by that code:

route[FROMASTERISK] {
   if(ds_is_from_list()){
        return 1;
   }
 return -1;
}
route[TOASTERISK] {
        ds_mark_dst("P");
        if(!ds_select_dst("1", "2")) { # i have only 2 sterisk in list
                sl_send_reply("500", "Service Unavailable");
                exit;
        }
 route(RELAY);
 exit;
}

And that'sall.. but:

NOTE. the code on TOASTERISK exit if service are unavailable,, i have
doubs about that, due i assume that if does not return (noted the "!"
in the contidional) from the list.. there's no way to deliver to a
asterisk.. so exit,cos i not have enought xpertise to propety code a
subrutine that waiths to an asterisk to be available!

HERE THE LAST PROBLEM:

taken from the asterisk realtime guide, just almost at the lasted
lines of the kamailio.cfg this is the code part that i cannot or i
does not have enoought knowledge to translate that rules
to the dispatcher ruling.. there are the code:

route[REGFWD] {
	if(!is_method("REGISTER"))
	{
		return;
	}
	$var(rip) = $sel(cfg_get.asterisk.bindip);
	$uac_req(method)="REGISTER";
	$uac_req(ruri)="sip:" + $var(rip) + ":" + $sel(cfg_get.asterisk.bindport);
	$uac_req(furi)="sip:" + $au + "@" + $var(rip);
	$uac_req(turi)="sip:" + $au + "@" + $var(rip);
	$uac_req(hdrs)="Contact: <sip:" + $au + "@"
				+ $sel(cfg_get.kamailio.bindip)
				+ ":" + $sel(cfg_get.kamailio.bindport) + ">\r\n";
	if($sel(contact.expires) != $null)
		$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) + "\r\n";
	else
		$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";
	uac_req_send();
}


2020-04-22 19:59 GMT-04:00, ospos web <osposweb at gmail.com>:
> Hi all folks, Hello people, I'm new and I've been reading, so I have
> some but not much knowledge.
>
> I must integrate as work, two asterisk to the kamailio, a month ago I
> started with the real time guide [1] with only one kamailio, register,
> start the call, etc.. I am with the basics and it works.
>
> Now I must put two asterisk and using dispatcher, but although I read
> the documentation of the module.. use it and so then configure a list
> of file (with the asterisk where to dispatch) and not in the
> database..
>
> MY HELP REQUEST QUESTION: How do I use dispatcher in load balancing
> mode, but taking in consideration my already working realtime-asterisk
> worling setup?
>
> THE PROBLEM: since with what I did it simply sends the call to both
> asterisk. i setup only 4 easy steps.. load module, then setup params
> (where i set the asterisk lists by file, and not db) and then added a
> "ds_select_dst(1, 4);" before the "route(RELAY);" line. please help!
>
> as i know.. the ds_select_dst(1, 4); prepare wicht asterisk will be
> choose to use and then when the routing RELAY happends no cares if in
> the realtime previously guide are a main asterisk? right?
>
> NOTE: I know it's a big world... but I can't keep reading the kamailio
> theory, i must goon forward due i have to lear later once are property
> working..
>
> [1]
> https://kb.asipto.com/asterisk:realtime:kamailio-4.0.x-asterisk-11.3.0-astdb
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>


-- 
Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com



More information about the sr-users mailing list