<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-ligatures:standardcontextual;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">I am using Opensips v.3.2 and I am attempting to replicate the 302 redirect outlined on the blog (<a href="https://blog.opensips.org/2018/07/05/handling-sip-redirect-requests-in-realtime/">https://blog.opensips.org/2018/07/05/handling-sip-redirect-requests-in-realtime/</a>),
 but am running into an odd issue.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am using exec to execute an external program, which returns a URI as a variable, which is then used to populate the $branch field, which is then returned as the contact URI in the 302 response.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">For reasons I cannot explain, even though the URI is correctly formatted in the xlogs which I print off during the call request, when the 302 message is received, the Contact URI is missing the end ‘>‘character. This means the server the
 302 is being sent to doesn’t ACK the message, as the contact URI is invalid.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If I specify the URI directly within OpenSIPs, then the contact header is then formatted correctly.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Initially I thought the issue was related to the script returning the variable (bash script), so I swapped to a Golang program, essentially returning the same URI, but the same behaviour occurs with this as well.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The script is setup as follows…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">        if ( $si == '10.10.14.71' && is_method("INVITE") ) {<o:p></o:p></p>
<p class="MsoNormal">                        exec("/usr/local/bin/sbc-route", $tU, $var(out));<o:p></o:p></p>
<p class="MsoNormal">                        xlog("Value returned from Re-direct Script is $var(out)");<o:p></o:p></p>
<p class="MsoNormal">                        $branch = $var(out);<o:p></o:p></p>
<p class="MsoNormal">                        xlog("Target is set as $branch");<o:p></o:p></p>
<p class="MsoNormal">                        send_reply(302, "Server Redirect");<o:p></o:p></p>
<p class="MsoNormal">                        exit;<o:p></o:p></p>
<p class="MsoNormal">        }<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Can anyone offer any ideas as to why this may be occurring?<o:p></o:p></p>
</div>
</body>
</html>