After endless tests, I tried to replace record_route_preset with insert_hf,
writing the complete record route headers. A light started to come out of
the tunnel.....
Suppose User A is registered to port 53, User B to port 5060.
In the case of double record route, when A sends an INVITE to B, I write
the following in the SIP header of the INVITE forwarded to B :
Record-Route: <sip:public_ip:5060;r2=on;lr=on>
Record-Route: <sip:public_ip:53;r2=on;lr=on>
The first transaction, INVITE / 200OK goes well, with Kamailio forwarding
packets correctly from the corresponding socket of each user.
The problem arises when User B sends BYE to the 5060 port, with both route
headers in the SIP header of the BYE. I get the following error :
WARNING: rr [loose.c:747]: no socket found for match second RR
after which Kamailio forwards the BYE from the 5060 socket to User A. User
A being registered on port 53, ignores the packet coming with source port
5060. The BYE is never replied to.
I guess that means that Kamailio is not able to find the private_ip:53
socket from the public_ip:53 record-route header.
I hope it was clear.
I think there's a fundamental issue with running Kamailio behind NAT and
listening on multiple port numbers. Am I the only one suffering from this
type of configuration?
(Part of the problem is also tied to dumb ALG NAT routers which try to
out-smart SIP servers, without which I wouldn't run Kamailio on multiple
ports, and life would be much easier)
RA
On Thu, Jan 19, 2012 at 01:00, Reda Aouad <reda.aouad(a)gmail.com> wrote:
Okay, it seems we're on the right track.. BUT
This is my code in the branch_route
if (is_method("INVITE|SUBSCRIBE")){
$avp(s:fs) = $fs;
$avp(s:Rp) = $Rp;
avp_subst("$avp(s:fs)", "/(.*):(.*):(.*)/\3/");
#xlog("fs: $avp(s:fs) | Rp: $avp(s:Rp)");
if ($avp(s:fs) == $avp(s:Rp)) {
record_route_preset("PUBLIC_IP:$avp(s:fs)");
return;
}
record_route_preset("PUBLIC_IP:$avp(s:fs)",
"PUBLIC_IP:$avp(s:Rp)");
}
return;
$avp(s:fs) is the outbound socket, on which I apply the avp_subst function
to extract only the outbound port number Kamailio should send from.
$avp(s:Rp) is the inbound port, the port on which Kamailio received the
INVITE.
Then if the above port numbers are equal, I do only one record route. If
not, I do double record routing, one per port number.
The problem is that for the first branch, everything works fine. But for
the subsequent branches, I get the following error :
ERROR: rr [rr_mod.c:256]: Duble attempt to record-route
It seems that for subsequent branches, Kamailio detects that it already
record routed the first branch, so gives an error and doesn't record route.
Reda