<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection">
<div dir="auto">Hi Henning/All,<br />
<br />
After some digging we realized the system was already retrying thanks to this block on kamailio.cfg<br />
<br />
<code># Try next destionations in failure route</code><span style="font-size: 16px"><br /></span><code>failure_route[RTF_DISPATCH] {</code><span style="font-size: 16px"><br /></span><code>    </code><strong><code>if</code></strong><span style="color:#333333;background-color:rgba(0, 0, 0, 0);font-family:Consolas, Bitstream Vera Sans Mono, Courier New, Courier, monospace;font-size: 16px"> </span><code>(t_is_canceled()) {</code><span style="font-size: 16px"><br /></span><code>        </code><code>exit;</code><span style="font-size: 16px"><br /></span><code>    </code><code>}</code><span style="font-size: 16px"><br /></span><code>    </code><code># next DST - only </code><strong><code>for</code></strong><span style="color:#333333;background-color:rgba(0, 0, 0, 0);font-family:Consolas, Bitstream Vera Sans Mono, Courier New, Courier, monospace;font-size: 16px"> </span><code>500</code><span style="color:#333333;background-color:rgba(0, 0, 0, 0);font-family:Consolas, Bitstream Vera Sans Mono, Courier New, Courier, monospace;font-size: 16px"> </span><code>or local timeout</code><span style="font-size: 16px"><br /></span><code>    </code><strong><code>if</code></strong><span style="color:#333333;background-color:rgba(0, 0, 0, 0);font-family:Consolas, Bitstream Vera Sans Mono, Courier New, Courier, monospace;font-size: 16px"> </span><code>(t_check_status(</code><code>"500"</code><code>)</code><span style="font-size: 16px"><br /></span><code>            </code><code>or (t_branch_timeout() and !t_branch_replied())) {</code><span style="font-size: 16px"><br /></span><code>        </code><strong><code>if</code></strong><code>(ds_next_dst()) {</code><span style="font-size: 16px"><br /></span><code>            </code><code>t_on_failure(</code><code>"RTF_DISPATCH"</code><code>);</code><span style="font-size: 16px"><br /></span><code>            </code><code>route(RELAY);</code><span style="font-size: 16px"><br /></span><code>            </code><code>exit;</code><span style="font-size: 16px"><br /></span><code>        </code><code>}</code><span style="font-size: 16px"><br /></span><code>    </code><code>}</code><span style="font-size: 16px"><br /></span><code>}</code><span style="font-size: 16px"><br /></span><span style="font-size: 16px"><br /></span>How can we control the maximum number of retries? Seems to be infinite at the moment? Or <span style="color:#000000;font-family:Consolas, Bitstream Vera Sans Mono, Courier New, Courier, monospace;font-size: 16px">!t_branch_replied()</span>means that each backend can only reply once?<br />
<br />
Thanks you<br /></div>
</div>
<div name="messageSignatureSection"><br />
<div class="matchFont">With best wishes,
<div dir="auto">Unai Rodriguez</div>
</div>
</div>
<div name="messageReplySection">On 6 Dec 2022, 10:04 +0100, Henning Westerholt <hw@gilawa.com>, wrote:<br />
<blockquote type="cite" style="border-left-color: grey; border-left-width: thin; border-left-style: solid; margin: 5px 5px;padding-left: 10px;">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hello,</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB">you can implement this by using a failure_route. There is one example in the dispatcher module configuration how to do it.</span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB">Cheers,</span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB">Henning</span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB"> </span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB">--</span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB">Henning Westerholt –</span> <span style="mso-fareast-language:EN-US"><a href="https://skalatan.de/blog/"><span lang="EN-GB" style="color:#0563C1" xml:lang="EN-GB">https://skalatan.de/blog/</span></a></span><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB"></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB">Kamailio services –</span> <span style="mso-fareast-language:EN-US"><a href="https://gilawa.com/"><span lang="EN-GB" style="color:#0563C1" xml:lang="EN-GB">https://gilawa.com</span></a></span><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB"></span></p>
</div>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US" xml:lang="EN-GB"> </span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b> sr-users <sr-users-bounces@lists.kamailio.org> <b>On Behalf Of</b> Unai Rodriguez<br />
<b>Sent:</b> Saturday, December 3, 2022 5:16 PM<br />
<b>To:</b> sr-users@lists.kamailio.org<br />
<b>Subject:</b> [SR-Users] How to have Kamailio retry backends</p>
</div>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"> </p>
<div name="messageBodySection">
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-family:"Arial",sans-serif">Dear List,</span><br />
<br />
<span style="font-family:"Arial",sans-serif">We’re using Kamailio to load balance MRCP requests to multiple backend groups with a configuration as follows:</span><br />
<br />
<span style="font-family:"Andale Mono",serif"># kamailio.cfg</span><br />
<span style="font-family:"Andale Mono",serif">...</span><br />
<span style="font-family:"Andale Mono",serif">...</span><br />
<span style="font-family:"Andale Mono",serif">route[DISPATCH] {</span><br />
<span style="font-family:"Andale Mono",serif">                if($ua=="mrcp_backend_1") {</span><br />
<span style="font-family:"Andale Mono",serif">                                if(!ds_select_dst("1", "4")) {</span><br />
<span style="font-family:"Andale Mono",serif">                                               send_reply("404", "No destination");</span><br />
<span style="font-family:"Andale Mono",serif">                                               exit;</span><br />
<span style="font-family:"Andale Mono",serif">                                }</span><br />
<span style="font-family:"Andale Mono",serif">                }</span><br />
<span style="font-family:"Andale Mono",serif">                if($ua=="mrcp_backend_2") {</span><br />
<span style="font-family:"Andale Mono",serif">                                if(!ds_select_dst("2", "4")) {</span><br />
<span style="font-family:"Andale Mono",serif">                                               send_reply("404", "No destination");</span><br />
<span style="font-family:"Andale Mono",serif">                                               exit;</span><br />
<span style="font-family:"Andale Mono",serif">                                }</span><br />
<span style="font-family:"Andale Mono",serif">                }</span><br />
<span style="font-family:"Andale Mono",serif">                xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");</span><br />
<span style="font-family:"Andale Mono",serif">                t_on_failure("RTF_DISPATCH");</span><br />
<span style="font-family:"Andale Mono",serif">                route(RELAY);</span><br />
<span style="font-family:"Andale Mono",serif">                exit;</span><br />
<span style="font-family:"Andale Mono",serif">}</span><br />
<span style="font-family:"Andale Mono",serif">...</span><br />
<span style="font-family:"Andale Mono",serif">...</span><br />
<br />
<span style="font-family:"Andale Mono",serif"># dispatcher.list</span><br />
<span style="font-family:"Andale Mono",serif">1 <a href="sip:mrcp01.server.int:8060;transport=tcp">sip:mrcp01.server.int:8060;transport=tcp</a></span><br />
<span style="font-family:"Andale Mono",serif">1 <a href="sip:mrcp02.server.int:8060;transport=tcp">sip:mrcp02.server.int:8060;transport=tcp</a></span><br />
<br />
<span style="font-family:"Andale Mono",serif">2 <a href="sip:mrcp03.server.int:8060;transport=tcp">sip:mrcp03.server.int:8060;transport=tcp</a></span><br />
<span style="font-family:"Andale Mono",serif">2 <a href="sip:mrcp04.server.int:8060;transport=tcp">sip:mrcp04.server.int:8060;transport=tcp</a></span><br />
<br />
With this configuration, Kamailio load balances the initial SIP INVITE among the MRCP servers. After the INVITE, the service communicates directly to the MRCP servers via SIP (for hanging up the call), MRCPv2 (for sending speech control messages), and RTP (for sending audio).<br />
<br />
We would like to implement a configurable number of retries, so that if a particular backend times out, Kamailio would retry X times to other backend(s). In short, <a href="https://cbonte.github.io/haproxy-dconv/2.4/configuration.html#4-retries" target="_blank">something equivalent to HAProxy’s retries</a>, but for Kamailio. This probably implies having Kamailio always as part of our communication (not just load balancing the initial SIP INVITE).<br />
<br />
I haven’t been able to find much information about this, could someone provide some pointers?<br />
<br />
Thank you so much</p>
</div>
</div>
<div name="messageSignatureSection">
<p class="MsoNormal" style="margin-left:35.4pt"> </p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">With best wishes,</p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Unai Rodriguez</p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</body>
</html>