Hello
Is there a possibility to send a reply from within a branch route?
Experimental case (yes, I know it's a non working set-up, but I just wonder if that would be possible).
Two registrar nodes, location information shared between the two.
CPE registers via TLS, therefore the existing connection shall be used towards the CPE and that only exists on one of the registrars.
So in the Branch Route I would like to do something like:
$var(socket) = $(ulc(aor=>socket)[$T_branch_idx]);
if ($var(socket) == 0) { send_reply("503","no local socket"); }
This would cause the core routing instance to select the next registrar from the dispatcher list which hopefully holds the active socket.
But none of the 'send_reply' variants seem to be allowed within a branch route.
Or is there a better solution?
Mit freundlichen Grüssen
-Benoît Panizzon-
You don't need to do so in branch route. You can do this within request_route.
On Thu, 4 May 2023, 12:55 Benoit Panizzon, benoit.panizzon@imp.ch wrote:
Hello
Is there a possibility to send a reply from within a branch route?
Experimental case (yes, I know it's a non working set-up, but I just wonder if that would be possible).
Two registrar nodes, location information shared between the two.
CPE registers via TLS, therefore the existing connection shall be used towards the CPE and that only exists on one of the registrars.
So in the Branch Route I would like to do something like:
$var(socket) = $(ulc(aor=>socket)[$T_branch_idx]);
if ($var(socket) == 0) { send_reply("503","no local socket"); }
This would cause the core routing instance to select the next registrar from the dispatcher list which hopefully holds the active socket.
But none of the 'send_reply' variants seem to be allowed within a branch route.
Or is there a better solution?
Mit freundlichen Grüssen
-Benoît Panizzon-
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
Hi Yuriy
You don't need to do so in branch route. You can do this within request_route.
Bug accessing:
$var(socket) = $(ulc(aor=>socket)[$T_branch_idx]);
Is only possible in the branch route as I need that index, right?
Mit freundlichen Grüssen
-Benoît Panizzon-
Asl ulc pseudovariable is a stack you can just iterate via it in the request_route see example here: https://kamailio.org/docs/modules/5.6.x/modules/registrar.html#idm871
чт, 4 мая 2023 г. в 15:38, Benoit Panizzon benoit.panizzon@imp.ch:
Hi Yuriy
You don't need to do so in branch route. You can do this within request_route.
Bug accessing:
$var(socket) = $(ulc(aor=>socket)[$T_branch_idx]);
Is only possible in the branch route as I need that index, right?
Mit freundlichen Grüssen
-Benoît Panizzon-
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________
Hi Benoit,
Branches are a hop-by-hop concept; that is, branch #1 is from calling UAC to the proxy, and branch #2 (and #N) is from the proxy to any upstream destinations. So, looking backward from the proxy toward the originating caller, there is no distinction between replying “on a branch” vs. just “replying”; they are one and the same.
The reason sending replies in branch_route is disallowed is because the intended purpose of branch_route is quite narrow: to make alterations to the SIP request which are scoped only to one branch and reverted on subsequent branches.
On the other hand, the problem you raise can be viewed in more general terms: given replication between two or more registrars, know to know if the registrant is “local”? Looking at the socket of the resolved contact is indeed a valid approach, but there are others.
My favourite approach is to use the Path header. While the primary use case of Path is when a proxy forwards a registration upstream to another registrar, Kamailio can also use it to determine whether a registrant is local:
https://kamailio.org/docs/modules/5.6.x/modules/registrar.html#registrar.p.p...
https://kamailio.org/docs/modules/5.6.x/modules/registrar.html#registrar.p.p...
Or in other words, if you do a lookup() and find that the next hop (i.e. $du) is == myself (assuming path_check_local == 0), you can presume that the current registrar is the “home registrar” for the device.
In the case of TCP and TLS (“reliable” / “streaming” transports, specifically), you can also preemptively test if the connection already exists using tcp_get_conid() from the `tcpops` module:
https://kamailio.org/docs/modules/5.6.x/modules/tcpops.html#tcpops.f.tcp_get...
That is, you can do a lookup(), then test whether a TCP connection exists to the recipient:
if(($nh(P) eq ’tcp' || $nh(P) eq ’tls') && !tcp_get_conid("$nh(d):$nh(p)", "$var(tcp_conid)”)) { send_reply(“410”, “Gone”); exit; }
However, this will not work for UDP for obvious reasons.
Hope it helps!
— Alex
On May 4, 2023, at 6:17 AM, Benoit Panizzon benoit.panizzon@imp.ch wrote:
Hello
Is there a possibility to send a reply from within a branch route?
Experimental case (yes, I know it's a non working set-up, but I just wonder if that would be possible).
Two registrar nodes, location information shared between the two.
CPE registers via TLS, therefore the existing connection shall be used towards the CPE and that only exists on one of the registrars.
So in the Branch Route I would like to do something like:
$var(socket) = $(ulc(aor=>socket)[$T_branch_idx]);
if ($var(socket) == 0) { send_reply("503","no local socket"); }
This would cause the core routing instance to select the next registrar from the dispatcher list which hopefully holds the active socket.
But none of the 'send_reply' variants seem to be allowed within a branch route.
Or is there a better solution?
Mit freundlichen Grüssen
-Benoît Panizzon-
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
Hi Alex
Thank you for your input. Determining if the call is for a locally registered user seems pretty easy.
Now the next challenge...
There might be multiple registered contacts for an AOR using multiple protocols and residing on different registrars.
I was considering using dispatcher mode 12 (parallel branching) towards the registrars and just send a call to both our registrars node.
But what happens, if there is only one contact registered, obviously on one registrar? The call sent to the 'wrong' registrar would get a reply like 408 not registered and possibly trigger the failure route to voicemail, while the other registrar is routing the call to the CPE?
Is there a solution for this scenario, or do I have to get rid of having two registrars for redundancy and HA reasons and would better do with only one node?
Mit freundlichen Grüssen
-Benoît Panizzon-
Hi,
If your proxy parallel-forks to both registrars, and one registrar replies with a negative final reply (like 408), that’s no problem. You still have branch #2 to the other registrar, and if that generates positive replies, it is those “winning “replies which will be relayed back to the caller, not the ones on the “losing” branch(es).
— Alex
On May 4, 2023, at 10:24 AM, Benoit Panizzon benoit.panizzon@imp.ch wrote:
Hi Alex
Thank you for your input. Determining if the call is for a locally registered user seems pretty easy.
Now the next challenge...
There might be multiple registered contacts for an AOR using multiple protocols and residing on different registrars.
I was considering using dispatcher mode 12 (parallel branching) towards the registrars and just send a call to both our registrars node.
But what happens, if there is only one contact registered, obviously on one registrar? The call sent to the 'wrong' registrar would get a reply like 408 not registered and possibly trigger the failure route to voicemail, while the other registrar is routing the call to the CPE?
Is there a solution for this scenario, or do I have to get rid of having two registrars for redundancy and HA reasons and would better do with only one node?
Mit freundlichen Grüssen
-Benoît Panizzon-
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________