<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,<br>
</p>
<div class="moz-cite-prefix">On 31.12.19 17:14, Dovid Bender wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAM3TTh3=fFWgzNxWMoZNWc9CgDbT3Zr27QPvesGSrx4wQojD6A@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Hi,
<div><br>
</div>
<div>First off please forgive my lack of knowledge on how TCP
works. <br>
<div><br>
</div>
<div>We are using Kamailio 5.0.7 and we have an issue where
clients are connecting via TCP and their NAT devices are
closing up. Because of this we want to send TCP keep alives
every so often.</div>
<div><br>
</div>
<div>1) When restarting Kamailio it's sends a RST. Is this
Kamailio sending it out or is it linux sending it when the
application is killed?</div>
</div>
</div>
</blockquote>
I think in this case is the linux doing the connections cleanup.<br>
<blockquote type="cite"
cite="mid:CAM3TTh3=fFWgzNxWMoZNWc9CgDbT3Zr27QPvesGSrx4wQojD6A@mail.gmail.com">
<div dir="ltr">
<div>
<div> The issue we have is if say we need to do a restart 2-3
times (yes we should normally do that) then we end up with
3x registrations in the db (since when using db mode if the
connection goes away it won't remove the reg from the db (as
per - <a
href="https://kamailio.org/docs/modules/5.0.x/modules/usrloc.html#usrloc.p.handle_lost_tcp"
moz-do-not-send="true">https://kamailio.org/docs/modules/5.0.x/modules/usrloc.html#usrloc.p.handle_lost_tcp</a>)<br>
<br>
2) I haven testing with the following settings.<br>
a. tcp_crlf_ping=yes<br>
b. tcp_keepcnt = 3<br>
c. tcp_keepidle = 5<br>
<br>
With the above I see the TCP keep alives coming in every 75
seconds. If I tcp_keepintvl = 10 then I see TCP keep alives
going out from Kamailio to the phone. As per <a
href="https://www.kamailio.org/wiki/cookbooks/5.0.x/core#tcp_keepintvl"
moz-do-not-send="true">https://www.kamailio.org/wiki/cookbooks/5.0.x/core#tcp_keepintvl</a>
it says "Time interval between keepalive probes, when the
previous probe failed". Looking at my captures Kamilio sends
out the TCP keep alive and gets it back. Is Kamailio not
seeing it? With the above it seems to be working the way I
want it but I want to make sure that I am doing it right.<br>
</div>
</div>
</div>
</blockquote>
<p><br>
</p>
<p>The tcp ping options are set to the socket and the kernel takes
care of tcp ping-pong. IIRC, the application doesn't get informed
when all these happen.</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:CAM3TTh3=fFWgzNxWMoZNWc9CgDbT3Zr27QPvesGSrx4wQojD6A@mail.gmail.com">
<div dir="ltr">
<div>
<div><br>
3) For the devs on here how hard would it be to implement
handle_lost_tcp for DB-Only?<br>
</div>
</div>
</div>
</blockquote>
<p><br>
</p>
<p>Probably you can already do it to some extent via config, like:</p>
<p>event_route[tcp:closed] {<br>
sql_query("delete from location where connection_id=$conid");<br>
}</p>
<p>In case you set attributes for contact, you have to fetch first
the ruid by connection id and delete also the records from
location_attrs.</p>
<p>But his will work for the connections that are closed during
runtime, not because of a restart.<br>
</p>
<p>To your question: adding it in the module will be a matter of
some C coding, nothing very complex, just a scan of the records in
the db to fetch ruid and connection_id, then check if connection
exists and if not, delete based on ruid from location and
location_attrs.</p>
<p>At the end, this can be also implemented via config, using rtimer
module to do a timer-based route execution with the sql queries
from above.</p>
<p>Or you make a shell script to delete all the tcp records when
restart is executed, because after the restart, the tcp connection
will not be available anyhow. Only be careful in case you have UAs
that register with a tcp contact address where it expects to get a
tcp connect and such UAs close the tcp connection after register
-- this is allowed by sip specs.<br>
</p>
<p>Cheers,<br>
Daniel<br>
</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:CAM3TTh3=fFWgzNxWMoZNWc9CgDbT3Zr27QPvesGSrx4wQojD6A@mail.gmail.com">
<div dir="ltr">
<div>
<div><br>
TIA and a happy new year to all.<br>
<br>
Regards,<br>
<br>
Dovid<br>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio World Conference - April 27-29, 2020, in Berlin -- <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
</body>
</html>