<div>Solved. Firewall problem.</div>
<div>&nbsp;</div>
<div>In case someone may run into this issue.</div>
<div>&nbsp;</div>
<div>There is a firewall between&nbsp;Asterisk&nbsp;and the database. The firewall kills an idle TCP connection after an hour. Asterisk and MySQL do not know this. Next time a call comes in, Asterisk reuses the connection. To make use of the connection, realtime pings the mysql first to check the connection. However, the firewall has killed/blocked the session so TCP on Asterisk side does not get an ACK. TCP then retries to transmit for about 15 minutes.</div>

<div>&nbsp;</div>
<div>Then after 2 hours TCP Keep-Alives on Asterisk server and MySQL server kicks in which does not help.</div>
<div>&nbsp;</div>
<div>Solution: Make TCP Keep-Alive kick in after 45 minutes of idle connection.</div>
<div>&nbsp;</div>
<div>R<br><br></div>
<div class="gmail_quote">On Thu, Mar 27, 2008 at 5:22 PM, Richard Open Source &lt;<a href="mailto:oss.richard@gmail.com">oss.richard@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Hi,</div>
<div>&nbsp;</div>
<div>I am investigating an issue with voicemail and realtime.</div>
<div>&nbsp;</div>
<div>What we are seeing is the following:</div>
<div>1. Caller calls in and goes to an IVR</div>
<div>2. Presses 101 to go to voicemail</div>
<div>3. app_voicemail start and tries to connect to&nbsp;the database trhough res_config_mysql.&nbsp;However, it takes too long to be able to connect (~15 minutes)</div>
<div>It seems like it first attemots to connect to the database on 16:25:03 and manage to connect at 16:40:24.</div>
<div>&nbsp;</div>
<div>[Mar 26 16:25:03] VERBOSE[19786] logger.c:&nbsp;&nbsp;&nbsp;&nbsp; -- AGI Script agi://<a href="http://127.0.0.1/enswitch?stype=external" target="_blank">127.0.0.1/enswitch?stype=external</a> completed, returning 0<br>[Mar 26 16:25:03] DEBUG[19786] pbx.c: Launching &#39;Answer&#39;<br>
[Mar 26 16:25:03] VERBOSE[19786] logger.c:&nbsp;&nbsp;&nbsp;&nbsp; -- Executing [101@enswitch-mailbox:1] Answer(&quot;SIP/5060-ac017e30&quot;, &quot;&quot;) in new stack<br>[Mar 26 16:25:03] DEBUG[19786] pbx.c: Expression result is &#39;0&#39;<br>
[Mar 26 16:25:03] DEBUG[19786] pbx.c: Launching &#39;GotoIf&#39;<br>[Mar 26 16:25:03] VERBOSE[19786] logger.c:&nbsp;&nbsp;&nbsp;&nbsp; -- Executing [101@enswitch-mailbox:2] GotoIf(&quot;SIP/5060-ac017e30&quot;, &quot;0?5&quot;) in new stack<br>
[Mar 26 16:25:03] DEBUG[19786] pbx.c: Not taking any branch<br>[Mar 26 16:25:03] DEBUG[19786] pbx.c: Launching &#39;VoiceMail&#39;<br>[Mar 26 16:25:03] VERBOSE[19786] logger.c:&nbsp;&nbsp;&nbsp;&nbsp; -- Executing [101@enswitch-mailbox:3] VoiceMail(&quot;SIP/5060-ac017e30&quot;, &quot;<a href="mailto:101@708%7Cus" target="_blank">101@708|us</a>&quot;) in new stack<br>
[Mar 26 16:25:03] DEBUG[19786] app_voicemail.c: Before find_user<br>[Mar 26 16:25:03] DEBUG[19786] app_voicemail.c: In find_user_realtime for mailbox 101 context 708<br></div>
<div>&nbsp;</div>
<div>[Mar 26 16:40:24] VERBOSE[14269] logger.c: Really destroying SIP dialog <a href="mailto:&#39;1004787600@127.0.0.1&#39;" target="_blank">&#39;1004787600@127.0.0.1&#39;</a> Method: OPTIONS<br>[Mar 26 16:40:28] ERROR[19786] res_config_mysql.c: MySQL RealTime: Ping failed (2006).&nbsp; Trying an explicit reconnect.<br>
[Mar 26 16:40:28] DEBUG[19786] res_config_mysql.c: MySQL RealTime: Server Error (2006): MySQL server has gone away<br>[Mar 26 16:40:28] DEBUG[19786] res_config_mysql.c: MySQL RealTime: Successfully connected to database.<br>
[Mar 26 16:40:28] DEBUG[19786] res_config_mysql.c: MySQL RealTime: Retrieve SQL: SELECT * FROM mailboxes WHERE mailbox = &#39;101&#39; AND context = &#39;708&#39;<br></div>
<div>The database and the connection seems to be ok. It is only this query that&#39;s taking long.</div>
<div>&nbsp;</div>
<div>We are experiencing this on Asterisk 1.4.17 and 1.4.18 but difficult to reproduce.</div>
<div>&nbsp;</div>
<div>Anybody have any idea what might be the cause and how to procceed and figure out what&#39;s wrong?</div>
<div>&nbsp;</div>
<div>Thanks in advance.</div>
<div>&nbsp;</div><font color="#888888">
<div>R</div></font></blockquote></div><br>