Hello Anthony,<div><br></div><div>Thanks. I have tested the registration-thread-frequency, but it seems this does not address the issue I&#39;m having here.</div><div><br></div><div>But the good news is: I just found the bug with the help of Alexandr Dubovikov...</div>
<div><br></div><div>In sofia_reg.c, sofia_reg_check_gateway(...) it reads:</div><div><br></div><div><div><font face="&#39;courier new&#39;, monospace">             if (gateway_ptr-&gt;freq &gt;= 60) {</font></div><div><font face="&#39;courier new&#39;, monospace">                      gateway_ptr-&gt;expires = now + (gateway_ptr-&gt;freq - 15);</font></div>
<div><font face="&#39;courier new&#39;, monospace">             } else {</font></div><div><font face="&#39;courier new&#39;, monospace">                     if (gateway_ptr-&gt;freq &lt; 30 &amp;&amp; gateway_ptr-&gt;freq &gt;= 5) {</font></div>
<div><font face="&#39;courier new&#39;, monospace">                             gateway_ptr-&gt;expires = now + (gateway_ptr-&gt;freq - 5);</font></div><div><font face="&#39;courier new&#39;, monospace">                     } else {</font></div>
<div><font face="&#39;courier new&#39;, monospace">                             gateway_ptr-&gt;expires = now + (gateway_ptr-&gt;freq);</font></div><div><font face="&#39;courier new&#39;, monospace">                     }</font></div>
<div><font face="&#39;courier new&#39;, monospace">             }</font></div></div><div><br></div><div>this results in a re-REGISTER 15 seconds ahead of expiration if the register timer is more than 60 seconds. We are a 5 seconds ahead of expiration if the register timer is between 5 and 29 seconds. And the winner is... if the register timer is between 30 and 59 seconds, we have no &quot;ahead&quot;. Obviously a bug, since the code is difficult to read with all those else conditions.</div>
<div><br></div><div>I created a patch, verified that is works and attached it to this mail. Let me know if I need to do more (open an issue etc.) to make sure this patch gets applied...</div><div><br></div><div>Thanks again,</div>
<div>Roland</div><div><br><br><div class="gmail_quote">2012/1/10 Anthony Minessale <span dir="ltr">&lt;<a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It might be because we only check for expiration every 30 seconds.<div><br></div><div>update to latest GIT and I added a profile param: registration-thread-frequency</div><div><br></div><div>The default is 30 so you can try setting it to 10 or 5 or something.</div>

<div><br></div><div><br><div><br><div><br><br><div class="gmail_quote">2012/1/9 Roland Hänel <span dir="ltr">&lt;<a href="mailto:roland@haenel.me" target="_blank">roland@haenel.me</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
Hi,<div><br></div><div>It seems that I&#39;m running into a timing issue with outgoing (gateway) registrations, which results in some milliseconds in that I can&#39;t send calls over that gateway.</div><div><br></div><div>


I have configured a gateway like this:</div><div><br></div><div><div><font face="&#39;courier new&#39;, monospace">            &lt;gateway name=&quot;duro&quot;&gt;</font></div><div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;username&quot; value=&quot;XXXXXXX&quot;/&gt;</font></div>


<div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;from-domain&quot; value=&quot;<a href="http://durosip.qsc.de" target="_blank">durosip.qsc.de</a>&quot;/&gt;</font></div><div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;password&quot; value=&quot;XXXXXXXXXXX&quot;/&gt;</font></div>


<div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;proxy&quot; value=&quot;<a href="http://durosip.qsc.de" target="_blank">durosip.qsc.de</a>&quot;/&gt;</font></div><div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;expire-seconds&quot; value=&quot;120&quot;/&gt;</font></div>


<div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;register&quot; value=&quot;true&quot;/&gt;^M</font></div><div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;register-transport&quot; value=&quot;udp&quot;/&gt;</font></div>


<div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;retry-seconds&quot; value=&quot;5&quot;/&gt;</font></div><div><font face="&#39;courier new&#39;, monospace">              &lt;param name=&quot;caller-id-in-from&quot; value=&quot;true&quot;/&gt;</font></div>


<div><span style="font-family:&#39;courier new&#39;,monospace">            &lt;/gateway&gt;^M</span></div><div><br></div><div>If I look at the &quot;200 OK&quot; messages for the SIP REGISTER packet, the server sends me an &quot;Expires: 30&quot;, so FreeSwitch should re-REGISTER every 30 seconds.</div>


<div><br></div><div>However, that&#39;s what happening:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><font face="&#39;courier new&#39;, monospace"><a href="tel:2012-01-09%2016" value="+12012010916" target="_blank">2012-01-09 16</a>:37:00.804865 [NOTICE] sofia_reg.c:407 Registering duro</font></div>


</div></div><div><div><div><font face="&#39;courier new&#39;, monospace"><a href="tel:2012-01-09%2016" value="+12012010916" target="_blank">2012-01-09 16</a>:37:31.804880 [NOTICE] sofia_reg.c:407 Registering duro</font></div>

</div></div><div><div><div><font face="&#39;courier new&#39;, monospace"><a href="tel:2012-01-09%2016" value="+12012010916" target="_blank">2012-01-09 16</a>:38:<a href="tel:03.804894" value="+493804894" target="_blank">03.804894</a> [NOTICE] sofia_reg.c:407 Registering duro</font></div>


</div></div><div><div><div><font face="&#39;courier new&#39;, monospace"><a href="tel:2012-01-09%2016" value="+12012010916" target="_blank">2012-01-09 16</a>:38:35.824877 [NOTICE] sofia_reg.c:407 Registering duro</font></div>

</div></div><div><div><div><font face="&#39;courier new&#39;, monospace"><b><a href="tel:2012-01-09%2016" value="+12012010916" target="_blank">2012-01-09 16</a>:39:<a href="tel:06.825090" value="+496825090" target="_blank">06.825090</a> [NOTICE] sofia_reg.c:407 Registering duro</b></font></div>


</div></div><div><div><div><font face="&#39;courier new&#39;, monospace"><a href="tel:2012-01-09%2016" value="+12012010916" target="_blank">2012-01-09 16</a>:39:39.824881 [NOTICE] sofia_reg.c:407 Registering duro</font></div>

</div></div></blockquote><div><div><br></div><div>You can see that it&#39;s <i>approximately</i> 30 seconds betwee registrations, but in fact every time it&#39;s just a little more than 30 secs. This alone makes me feel a little bit strange, since my registration might have been expired during this time window (and consequently, maybe I&#39;m loosing incoming calls because of that).</div>


<div><br></div><div>Even for outgoing calls, this seems to be an issue, let&#39;s take a look at the 16:39:<a href="tel:06.825090" value="+496825090" target="_blank">06.825090</a> re-REGISTER.</div><div><br></div><div>We can see that at 16:39:05 (no micro-seconds here) the gateway becomes &quot;UNREGED&quot;:</div>


<div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div><font face="&#39;courier new&#39;, monospace">Content-Length: 542</font></div></div></div><div><div><font face="&#39;courier new&#39;, monospace">Content-Type: text/event-plain</font></div>


</div><div><div><font face="&#39;courier new&#39;, monospace"><br></font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Event-Subclass: sofia::gateway_state</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Event-Name: CUSTOM</font></div>


</div><div><div><font face="&#39;courier new&#39;, monospace">Core-UUID: 243269fe-d280-4f83-aca1-abb88f2ad258</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">FreeSWITCH-Hostname: lap597</font></div>


</div><div><div><font face="&#39;courier new&#39;, monospace">FreeSWITCH-Switchname: lap597</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">FreeSWITCH-IPv4: 192.168.232.164</font></div></div><div>


<div><font face="&#39;courier new&#39;, monospace">FreeSWITCH-IPv6: ::1</font></div></div><div><div><font face="&#39;courier new&#39;, monospace"><b>Event-Date-Local: <a href="tel:2012-01-09%2016" value="+12012010916" target="_blank">2012-01-09 16</a>:39:05</b></font></div>

</div><div><div><font face="&#39;courier new&#39;, monospace">Event-Date-GMT: Mon, 09 Jan  2012  15:39:05 GMT</font></div>
</div><div><div><font face="&#39;courier new&#39;, monospace">Event-Date-Timestamp: 1326123545824882</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Event-Calling-File: sofia_reg.c</font></div></div>


<div><div><font face="&#39;courier new&#39;, monospace">Event-Calling-Function: sofia_reg_fire_custom_gateway_state_event</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Event-Calling-Line-Number: 151</font></div>


</div><div><div><font face="&#39;courier new&#39;, monospace">Gateway: duro</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">State: UNREGED</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Ping-Status: UP</font></div>


</div></blockquote><div><div><br></div><div>But the new REGISTER is done a full second later (this is not just a display issue, I saw those messages scrolling by and there was just a second pause between them):</div><div>


<br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><font face="&#39;courier new&#39;, monospace">Event-Subclass: sofia::gateway_state</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Event-Name: CUSTOM</font></div>


</div><div><div><font face="&#39;courier new&#39;, monospace">Core-UUID: 243269fe-d280-4f83-aca1-abb88f2ad258</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">FreeSWITCH-Hostname: lap597</font></div>


</div><div><div><font face="&#39;courier new&#39;, monospace">FreeSWITCH-Switchname: lap597</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">FreeSWITCH-IPv4: 192.168.232.164</font></div></div><div>


<div><font face="&#39;courier new&#39;, monospace">FreeSWITCH-IPv6: ::1</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Event-Date-Local: <a href="tel:2012-01-09%2016" value="+12012010916" target="_blank">2012-01-09 16</a>:39:06</font></div>

</div><div><div><font face="&#39;courier new&#39;, monospace"><b>Event-Date-GMT: Mon, 09 Jan 2012 15:39:06 GMT</b></font></div>
</div><div><div><font face="&#39;courier new&#39;, monospace">Event-Date-Timestamp: 1326123546825090</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Event-Calling-File: sofia_reg.c</font></div></div>


<div><div><font face="&#39;courier new&#39;, monospace">Event-Calling-Function: sofia_reg_fire_custom_gateway_state_event</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Event-Calling-Line-Number: 151</font></div>


</div><div><div><font face="&#39;courier new&#39;, monospace">Gateway: duro</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">State: TRYING</font></div></div><div><div><font face="&#39;courier new&#39;, monospace">Ping-Status: DOWN</font></div>


</div></blockquote><div><div><br></div><div>Then, the gateway gets re-registered in a couple of milliseconds and everything is fine again.</div><div><br></div><div><b>It seems that this behaviour effectively creates a timespan of 1-2 seconds, where the gateway is not available for outgoing (and maybe also incoming) calls.</b></div>


<div><br></div><div>Does anyone of you know this issue? I wonder because this looks just to easy to be wrong in this fashion?</div><div><br></div>Greetings,<div>Roland</div><div><br></div><br>
</div>
<br></div></div>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com/</a><br>

Twitter: <a href="http://twitter.com/FreeSWITCH_wire" target="_blank">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com" target="_blank">MSN:anthony_minessale@hotmail.com</a><br>
GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com" target="_blank">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org" target="_blank">sip:888@conference.freeswitch.org</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org" target="_blank">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:<a href="tel:%2B19193869900" value="+19193869900" target="_blank">+19193869900</a><br>
</div></div></div>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Gruß,<div>Roland</div><div><br></div><br>
</div>