<div dir="ltr">There are various suggested solutions out there. On the Nginx config side, easiest is to increase the <code>proxy_read_timeout </code>setting to something high, but that seems like it could result in connections getting hung open if the server process goes away.<div><br></div><div>Then there’s this module which looks pretty fancy and claims to solve the problem: <a href="https://github.com/yaoweibin/nginx_tcp_proxy_module">https://github.com/yaoweibin/nginx_tcp_proxy_module</a> — it requires custom compiling nginx though…</div><div><br></div><div>I think I’ll stick with my current solution, which basically follows the other suggestion of having the server send periodic keepalives, except that I’m initiating from the client. Steps for others interested:</div><div><br></div><div>1. Add ‘echo’ to the list of jsonrpc-allowed-methods in any relevant domains in your user directory</div><div><br></div><div>2. Do something like this after a successful websocket connection:</div><div><br></div><div><div> MODULE.keepAliveTimer = setInterval(function() {</div><div> verto.rpcClient.call("echo", {keepalive: true});</div><div> }, VERTO_KEEPALIVE_INTERVAL)</div></div><div><br></div><div>3. Add some cleanup on websocket close:</div><div><br></div><div><div> if (MODULE.keepAliveTimer) {</div><div> clearInterval(MODULE.keepAliveTimer);</div><div> MODULE.keepAliveTimer = null;</div><div> }</div></div><div><br></div><div>Request and response lengths are both under 150 characters, so pretty short, and I set the intervals at 50 seconds, since Nginx’s default timeout is 60 seconds.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 6, 2017 at 6:39 AM, Mundkowsky, Robert <span dir="ltr"><<a href="mailto:rmundkowsky@ets.org" target="_blank">rmundkowsky@ets.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="m_-835003064064081181WordSection1">
<p class="MsoNormal"><a name="m_-835003064064081181__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Have you checked if Nginx has timeout settings and/or keep alive settings?<u></u><u></u></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><a href="https://stackoverflow.com/questions/10550558/nginx-tcp-websockets-timeout-keepalive-config" target="_blank"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">https://stackoverflow.com/<wbr>questions/10550558/nginx-tcp-<wbr>websockets-timeout-keepalive-<wbr>config</span></a><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Robert
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> FreeSWITCH-users [mailto:<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-<wbr>bounces@lists.freeswitch.org</a>]
<b>On Behalf Of </b>Chad Phillips<br>
<b>Sent:</b> Thursday, October 5, 2017 11:07 PM<br>
<b>To:</b> FreeSWITCH Users Help <<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.<wbr>freeswitch.org</a>><br>
<b>Subject:</b> [Freeswitch-users] Sending keepalives on Verto websocket<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">I've switched to using Nginx to proxy Verto websockets, and have run into a small snag: by default, if Nginx doesn't read any data from a proxy backend within 60 seconds, it closes the connection, even for websockets.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">It appears the recommended solution is to have the server send some kind of regular keepalive. I poked around in mod_verto.c and found a 'request.keepalive' variable, but I'm unclear how to set that in the request, and/or if it even accomplishes
what I'm wanting.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I've solved the issue for now by periodically sending a JSON RPC 'echo' request along the websocket every 50 seconds, and the reply from the server is enough to keep the connection open. This is fine, but I am curious if there's a way to
do it just from the server side, and if not, if it's worth it to add a setting to enable that functionality?<u></u><u></u></p>
</div>
</div>
</span></div>
<br>
<hr>
<p>This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender;
do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited.</p>
<br>
<p>Thank you for your compliance.</p>
<hr>
</div>
<br>______________________________<wbr>______________________________<wbr>_____________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.<wbr>freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.<wbr>org</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" 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.<wbr>freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/<wbr>mailman/listinfo/freeswitch-<wbr>users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.<wbr>freeswitch.org/mailman/<wbr>options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br></div>