[SR-Users] nat_keepalive() and fix_contact() are incompatible - SOLVED
David
kamailio.org at spam.lublink.net
Thu May 23 16:32:56 CEST 2013
Hello,
So the state file was easy because it showed up in syslog :
May 23 10:30:05 kamailio-dev-nat /usr/sbin/kamailio[15119]: ERROR:
nat_traversal [nat_traversal.c:1617]: failed to open keepalive state
file for writing: Permission denied
May 23 10:30:05 kamailio-dev-nat /usr/sbin/kamailio[15119]: ERROR: ctl
[ctl.c:379]: ERROR: ctl: could not delete unix socket /tmp/kamailio_ctl:
Operation not permitted (1)
The file was owned by root and not kamailio, I guess I must have run
kamailio as root at some point.
So I simply deleted the file and retested, everything is working!
Thanks,
David
On 13-05-23 10:27 AM, David wrote:
> Hello,
>
> I was using add_path() to add the path, in this case it was the wrong
> method.
>
> To anyone who runs into the same problem as me, the solution is that
> the proxy doing nat should have add_path_received() instead of
> add_path() and the proxy should also have the parameter
> modparam("path", "use_received", 1). Also, loose_route() has to be
> called even if there is no to tag so that the incoming requests are
> routed to the phone.
>
> With this the keep alives are sent every 20 seconds, so that's good.
> Trouble is, the state file is not being written. I will see if I can
> figure out why and post back my results.
>
> David
>
> On 13-05-23 04:04 AM, Daniel-Constantin Mierla wrote:
>> Hello,
>>
>> if you have registrar behind a proxy, then you have to use path module.
>>
>> Cheers,
>> Daniel
>>
>> On 5/22/13 3:17 PM, David wrote:
>>> Hello,
>>>
>>> fix_nated_register() doesn't seem to apply in this case because my
>>> NAT proxy is seperate from my usrloc proxy. I guess I forgot that
>>> information in my first email. Sorry.
>>>
>>> I tried using add_contact_alias, but it does the same thing.
>>>
>>> Is there an example somewhere of how to use the nat keep alive
>>> option on a server that does NAT before t_relaying it to another
>>> server that has usrloc on it?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>> On 13-05-22 04:06 AM, Klaus Darilion wrote:
>>>>
>>>>
>>>> On 21.05.2013 18:37, David wrote:
>>>>> 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 at mytld#015#012#015#012 is not reply
>>>>> sip:username at 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().
>>>>
>>>> Even if you do not call fix_contact I fail to see how the URIs
>>>> should match, as the contact URI in the response has the "expires"
>>>> parameter and therefore the string comparison should fail.
>>>>
>>>>> 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.
>>>>
>>>> That would be a solution. Another solution would be to use
>>>> fix_nated_register() for REGISTER and add_contact_alias() for other
>>>> requests (from nathelper module)
>>>>
>>>> regards
>>>> Klaus
>>>>
>>>>
>>>>>
>>>>> Any ideas what to do next ?
>>>>>
>>>>> Thanks,
>>>>> David
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing
>>>>> list
>>>>> sr-users at lists.sip-router.org
>>>>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>>>>
>>>
>>>
>>> _______________________________________________
>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>>> sr-users at lists.sip-router.org
>>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
More information about the sr-users
mailing list