Hello,
So I want to setup a Kamailio SIP Proxy( version 4 ) that will do NAT
signalling handling. With the help of nat_traversal and path modules.
Attached is my kamailio.cfg file.
My problem is I want to do keep alive on users who are behind NAT, so I
called nat_keepalive();. The script will work fine, but as soon as I
enable either add_contact_alias() or fix_contact(), the keep alive
doesn't activate.
I modified nat_traversal.c to identify the issue and found that it is
comparing the contact header from the request and the reply to find the
expiration. Trouble is, the request contact header was taken from before
I called fix_contact() and the reply header has the contact from after
the fix_contact() call. So my traces show that on the return trip the
callback is called, I bet the stack trace looks like this :
1. Some method in tm
2. __tm_reply_in() defined at nat_traversal.c:1358
3. get_register_expire called from nat_traversal.c:1377 and defined at
nat_traversal.c:878
4. STR_MATCH_STR called from nat_traversal.c:937 and defined at
nat_traversal.c:77
STR_MATCH_STR returns false because the headers are different.
I added
else
{
LM_ERR("failed to match because request
%s is not reply %s", contact->uri.s, r_contact->uri.s ) ;
}
to the code and see :
May 21 12:18:52 kamailio-dev-nat /usr/sbin/kamailio[30163]: ERROR:
nat_traversal [nat_traversal.c:946]: failed to match because request
sip:username@mytld#015#012#015#012 is not reply
sip:username@myip:59080>;expires=60;received="sip:64.18.189.196:5060"#015#012Server:
CenseredUA 5.2-rc1#015#012Content-Length: 0#015#012#015
So as you can see the original Contact header has the server's domain
name and the response has the IP address that set by fix_contact().
So I think that nat_keepalive() should not be comparing the Contact from
the original request but using the contact header from the modified request.
Any ideas what to do next ?
Thanks,
David