<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="monospace">Hi Ben,<br>
      <br>
      Use paging (index and count) when fetching the dialgs:<br>
<a class="moz-txt-link-freetext" href="https://opensips.org/html/docs/modules/3.6.x/dialog.html#mi_dlg_list">https://opensips.org/html/docs/modules/3.6.x/dialog.html#mi_dlg_list</a><br>
      <br>
      Regards,<br>
    </font>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a class="moz-txt-link-freetext" href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a>
  <a class="moz-txt-link-freetext" href="https://www.siphub.com">https://www.siphub.com</a></pre>
    <div class="moz-cite-prefix">On 09.07.2025 13:11, Ben Laing via
      Users wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CWXP123MB6191287D2F5FAB286EAB1534D849A@CWXP123MB6191.GBRP123.PROD.OUTLOOK.COM">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator"
        content="Microsoft Word 15 (filtered medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}@font-face
        {font-family:remialcxesans;
        panose-1:2 11 6 4 2 2 2 2 2 4;}@font-face
        {font-family:zone-1;
        panose-1:2 11 6 4 2 2 2 2 2 4;}@font-face
        {font-family:zones-AQ;
        panose-1:2 11 6 4 2 2 2 2 2 4;}@font-face
        {font-family:Menlo;
        panose-1:2 11 6 9 3 8 4 2 2 4;}@font-face
        {font-family:template-W0koJ2B3Ee-9_WBFvcEnUA;
        panose-1:2 11 6 4 2 2 2 2 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;
        mso-ligatures:standardcontextual;
        mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#467886;
        text-decoration:underline;}span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Aptos",sans-serif;
        color:windowtext;}p.p1, li.p1, div.p1
        {mso-style-name:p1;
        margin:0cm;
        font-size:11.5pt;
        font-family:Menlo;
        color:black;}span.s1
        {mso-style-name:s1;}span.apple-converted-space
        {mso-style-name:apple-converted-space;}.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}div.WordSection1
        {page:WordSection1;}</style>
      <div class="WordSection1">
        <p class="MsoNormal">Hi folks,<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I’m using OpenSIPs as a load balancer in an
          active/active setup. I’m trying to set up call re-homing when
          a node in the cluster goes down, largely following
          <a
href="https://blog.opensips.org/2019/10/03/re-homing-your-calls-with-opensips-3-0/"
            moz-do-not-send="true" class="moz-txt-link-freetext">
https://blog.opensips.org/2019/10/03/re-homing-your-calls-with-opensips-3-0/</a>
          . I’ve got separate shtags lb1 and lb2 for each node.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">When the cluster down is detected, I am
          running a python script that sets the remaining node as active
          then aims to rehome the calls in progress. Currently, that
          works by getting dlg_list_ctx, then running
          dlg_send_sequential for each dialog with a shtag matching the
          down node (dialog[‘context’][‘values’][‘dlgX_shtag’].<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="p1">That’s fine for a few calls, but fails when we get
          to a few hundred because the dlg_list_ctx throws an error:<br>
          <span class="s1">Jul</span><span class="apple-converted-space"> 
          </span><span class="s1">9 09:47:00 ip-10-4-40-11
            /usr/sbin/opensips[83438]: ERROR:core:print_mi_response:
            Failed to print JSON</span><o:p></o:p></p>
        <p class="p1"><span class="s1">Jul</span><span
            class="apple-converted-space">  </span>
          <span class="s1">9 09:47:00 ip-10-4-40-11
            /usr/sbin/opensips[83438]:
            ERROR:mi_<a class="moz-txt-link-freetext" href="http:mi_json_answer_to_connection">http:mi_json_answer_to_connection</a>: failed to print
            json response</span><o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Any ideas recommendations on how to tackle
          this?<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I could use dlg_list_ctx specifying an
          index/counter to complete in batches, but I’m not quite sure
          how the indexing works so there’s a worry we’d miss calls.
          E.g. we do calls 0-40 then 41-80 but if call 0 ends while
          processing 0-40, does that mean call 41 becomes call 40 so
          it’s missed from the 41-80 batch.<o:p></o:p></p>
        <p class="MsoNormal"><br>
          Probably the best solution I have at the moment is to query
          the DB directly to get the definitively list of call ids, then
          run dlg_list_ctx specifying and iID then dlg_send_sequential
          if appropriate. Or just don’t bother checking and run
          dlg_send_sequential on them all.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Any thoughts / suggestions?<o:p></o:p></p>
        <div>
          <table class="MsoNormalTable"
            style="width:100.0%;border-collapse:collapse" width="100%"
            cellspacing="0" cellpadding="0" border="0">
            <tbody>
              <tr>
                <td style="padding:0cm 0cm 0cm 0cm" valign="top">
                  <p class="MsoNormal">Best,<o:p></o:p></p>
                  <table class="MsoNormalTable"
                    style="width:100.0%;border-collapse:collapse"
                    width="100%" cellspacing="0" cellpadding="0"
                    border="0">
                    <tbody>
                      <tr>
                        <td style="padding:0cm 0cm 1.5pt 0cm"
                          valign="top">
                          <p class="MsoNormal"><o:p> </o:p></p>
                          <table class="MsoNormalTable"
style="width:100.0%;border-collapse:collapse" width="100%"
                            cellspacing="0" cellpadding="0" border="0">
                            <tbody>
                              <tr>
                                <td style="padding:0cm 0cm 0cm 0cm"
                                  valign="top">
                                  <p class="MsoNormal"
                                    style="text-align:right"
                                    align="right"><span
style="font-size:7.5pt;font-family:"Calibri",sans-serif;color:white">‑‑‑‑‑</span><span
style="font-size:7.5pt;font-family:"Calibri",sans-serif;color:white;mso-ligatures:none"><o:p></o:p></span></p>
                                </td>
                              </tr>
                              <tr>
                                <td style="padding:0cm 0cm 0cm 0cm"
                                  valign="top">
                                  <table class="MsoNormalTable"
                                    style="border-collapse:collapse"
                                    cellspacing="0" cellpadding="0"
                                    border="0">
                                    <tbody>
                                      <tr>
                                        <td
style="background:white;padding:0cm 0cm 0cm 0cm" valign="top">
                                          <table class="MsoNormalTable"
style="border-collapse:collapse" cellspacing="0" cellpadding="0"
                                            border="0">
                                            <tbody>
                                              <tr>
                                                <td
style="padding:0cm 0cm 0cm 0cm" valign="bottom">
                                                  <table
class="MsoNormalTable" style="border-collapse:collapse" cellspacing="0"
                                                    cellpadding="0"
                                                    border="0">
                                                    <tbody>
                                                      <tr>
                                                        <td
style="padding:0cm 7.5pt 3.75pt 0cm" valign="bottom">
                                                          <table
class="MsoNormalTable" style="border-collapse:collapse" cellspacing="0"
cellpadding="0" border="0">
                                                          <tbody>
                                                          <tr>
                                                          <td
style="padding:0cm 0cm 0cm 0cm" valign="top">
                                                          <table
class="MsoNormalTable" style="border-collapse:collapse" cellspacing="0"
cellpadding="0" border="0">
                                                          <tbody>
                                                          <tr>
                                                          <td
style="padding:0cm 0cm 0cm 0cm" valign="top">
                                                          <p
class="MsoNormal"><b><span
style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#1E285F">Ben Laing</span></b><b><span
style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#1E285F"><o:p></o:p></span></b></p>
                                                          </td>
                                                          <td
style="padding:0cm 0cm 0cm 0cm" valign="top">
                                                          <p
class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1111EE"> </span><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1111EE"><o:p></o:p></span></p>
                                                          </td>
                                                          <td
style="padding:0cm 0cm 0cm 0cm" valign="bottom">
                                                          <p
class="MsoNormal"><span
style="font-size:9.0pt;font-family:"Calibri",sans-serif;color:#BEC2B9">He/Him</span><span
style="font-size:9.0pt;font-family:"Calibri",sans-serif;color:#BEC2B9"><o:p></o:p></span></p>
                                                          </td>
                                                          </tr>
                                                          </tbody>
                                                          </table>
                                                          </td>
                                                          </tr>
                                                          <tr>
                                                          <td
style="padding:0cm 0cm 0cm 0cm" valign="top">
                                                          <p
class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#1E285F">Senior Software Developer</span><span
style="font-size:11.0pt;font-family:"Arial",sans-serif;color:#1E285F"><o:p></o:p></span></p>
                                                          </td>
                                                          </tr>
                                                          </tbody>
                                                          </table>
                                                        </td>
                                                      </tr>
                                                    </tbody>
                                                  </table>
                                                </td>
                                                <td
style="border:none;border-left:solid #BEC2B9 1.0pt;padding:0cm 0cm 0cm 0cm"
                                                  valign="bottom">
                                                  <table
class="MsoNormalTable" style="border-collapse:collapse" cellspacing="0"
                                                    cellpadding="0"
                                                    border="0">
                                                    <tbody>
                                                      <tr>
                                                        <td
style="padding:0cm 0cm 3.75pt 7.5pt" valign="bottom">
                                                          <table
class="MsoNormalTable" style="border-collapse:collapse" cellspacing="0"
cellpadding="0" border="0">
                                                          <tbody>
                                                          <tr>
                                                          <td
style="padding:0cm 0cm 0cm 0cm" valign="top">
                                                          <p
class="MsoNormal"><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#BEC2B9">Email: <u><a class="moz-txt-link-abbreviated" href="mailto:ben.laing@dals.co.uk">ben.laing@dals.co.uk</a></u></span><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#BEC2B9"><o:p></o:p></span></p>
                                                          </td>
                                                          </tr>
                                                          <tr>
                                                          <td
style="padding:0cm 0cm 0cm 0cm" valign="top">
                                                          <p
class="MsoNormal"><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#BEC2B9"><a
href="http://www.dals.co.uk/" target="_blank" title="www.dals.co.uk"
moz-do-not-send="true"><span style="color:#BEC2B9;text-decoration:none">Website: </span><span
style="color:#BEC2B9">www.dals.co.uk</span></a><o:p></o:p></span></p>
                                                          </td>
                                                          </tr>
                                                          </tbody>
                                                          </table>
                                                        </td>
                                                      </tr>
                                                    </tbody>
                                                  </table>
                                                </td>
                                              </tr>
                                            </tbody>
                                          </table>
                                        </td>
                                      </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                </td>
              </tr>
              <tr>
                <td style="padding:0cm 0cm 0cm 0cm" valign="top">
                  <p class="MsoNormal"><b><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#1E285F">Dals,
                        Statham House, Talbot Rd, Stretford, Manchester,
                        M32 0FP</span></b><b><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#1E285F"><o:p></o:p></span></b></p>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <p class="MsoNormal"><span
            style="font-size:1.0pt;font-family:remialcxesans"> </span><span
style="font-size:1.0pt;font-family:"template-W0koJ2B3Ee-9_WBFvcEnUA",serif"> </span><span
            style="font-size:1.0pt;font-family:zone-1"> </span><span
            style="font-size:1.0pt;font-family:zones-AQ"> </span><o:p></o:p></p>
      </div>
      <br>
      <p
style="font-family:Calibri;font-size:10pt;color:#000000;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;"
        align="Left">
        Classified - General<br>
      </p>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>