<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<font face="monospace">Out of curiosity, if you replace the:<br>
$branch = $var(out);<br>
with<br>
$ru = $var(out)<br>
is the reply properly formed ?<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 11/15/23 12:19 PM, Ben Bliss wrote:<br>
</div>
<blockquote type="cite"
cite="mid:LO2SPR01MB018AFEA7210953CA10C695FCB1A@LO2SPR01MB01.GBRP123.PROD.OUTLOOK.COM">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<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:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}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;}pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
font-size:10.0pt;
font-family:"Courier New";}span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}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]-->
<div class="WordSection1">
<p class="MsoNormal">HI Bogdan,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks for the reply.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I was using 3.2.13, so I have now patched
this to 3.2.15, which is the latest version on the 3.2 branch.
I repeated the test and got the same behaviour. Please see the
below information as requested…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Script…<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">Xlog information logged when the call
request comes in…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">2023-11-15T09:52:55.375039+00:00
uk-rdh-testast2 /usr/sbin/opensips[283656]: Value returned
from Re-direct Script is
<a href="sip:33557719673@10.10.4.77" moz-do-not-send="true">sip:33557719673@10.10.4.77</a><o:p></o:p></p>
<p class="MsoNormal">2023-11-15T09:52:55.375456+00:00
uk-rdh-testast2 /usr/sbin/opensips[283656]: Target is set as
<a href="sip:33557719673@10.10.4.77" moz-do-not-send="true">sip:33557719673@10.10.4.77</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The 302 response is below, exported from
Wireshark…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">No. Time
Source Destination Protocol Length
Info<o:p></o:p></p>
<p class="MsoNormal">15 09:53:20.012882 10.10.12.70
10.10.14.71 SIP 666 Status: 302 Server
Redirect |
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Frame 15: 666 bytes on wire (5328 bits),
666 bytes captured (5328 bits)<o:p></o:p></p>
<p class="MsoNormal">Ethernet II, Src: bb:bb:bb:bb:bb:bb
(bb:bb:bb:bb:bb:bb), Dst: aa:aa:aa:aa:aa:aa
(aa:aa:aa:aa:aa:aa)<o:p></o:p></p>
<p class="MsoNormal">Internet Protocol Version 4, Src:
10.10.12.70, Dst: 10.10.14.71<o:p></o:p></p>
<p class="MsoNormal">User Datagram Protocol, Src Port: 5070, Dst
Port: 5060<o:p></o:p></p>
<p class="MsoNormal">Session Initiation Protocol (302)<o:p></o:p></p>
<p class="MsoNormal"> Status-Line: SIP/2.0 302 Server
Redirect<o:p></o:p></p>
<p class="MsoNormal"> Message Header<o:p></o:p></p>
<p class="MsoNormal"> From: <a
href="sip:+4478341xxxxx@151.x.xxx.x;user=phone"
moz-do-not-send="true">
sip:+4478341xxxxx@151.x.xxx.x;user=phone</a>;tag=BN1699364674-1-1700041999-377836318<o:p></o:p></p>
<p class="MsoNormal"> To: <a
href="sip:+4415279xxxxx@149.x.xxx.xx;user=phone"
moz-do-not-send="true">
sip:+4415279xxxxx@149.x.xxx.xx;user=phone</a>;tag=5d8f.6023fbda08f41f7e9ebdc611f91805ef<o:p></o:p></p>
<p class="MsoNormal"> Call-ID: <a
href="mailto:55197572_103382176@151.x.xxx.x"
moz-do-not-send="true">
55197572_103382176@151.x.xxx.x</a><o:p></o:p></p>
<p class="MsoNormal"> [Generated Call-ID: <a
href="mailto:55197572_103382176@151.x.xxx.x"
moz-do-not-send="true">
55197572_103382176@151.x.xxx.x</a>]<o:p></o:p></p>
<p class="MsoNormal"> CSeq: 61414 INVITE<o:p></o:p></p>
<p class="MsoNormal"> Via: SIP/2.0/UDP
10.10.14.71:5060;branch=z9hG4bK-6a03d713-a7b27-28f11294-7f0923fc1278<o:p></o:p></p>
<p class="MsoNormal"> Via: SIP/2.0/UDP
149.x.xxx.xx:5060;received=151.x.xxx.x;rport=5060;branch=z9hG4bK1699364674<o:p></o:p></p>
<p class="MsoNormal"> Via: SIP/2.0/UDP
151.x.xxx.x:5060;branch=z9hG4bK0aB2fefabe20ff62d0e<o:p></o:p></p>
<p class="MsoNormal"> Contact:
<<a class="moz-txt-link-freetext" href="sip:33557719673@10.10.4.77">sip:33557719673@10.10.4.77</a><o:p></o:p></p>
<p class="MsoNormal"> [Expert Info (Warning/Malformed):
Header has no colon after the name]<o:p></o:p></p>
<p class="MsoNormal"> [Header has no colon after the
name]<o:p></o:p></p>
<p class="MsoNormal"> [Severity level: Warning]<o:p></o:p></p>
<p class="MsoNormal"> [Group: Malformed]<o:p></o:p></p>
<p class="MsoNormal"> Server: OpenSIPS (3.2.15
(x86_64/linux))<o:p></o:p></p>
<p class="MsoNormal"> Content-Length: 0<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">If it is any help, I did try another method
of inputting the Contact header, which was using the
‘append_to_reply’ command, rather than using the $branch
method, so I just formatted in the URI as such…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">append_to_reply('Contact:
<$var(out)>');<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This pushed the closing > from the
‘Contact’ URI to the “Server” line, as you can see on the
outputted 302 below…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">No. Time
Source Destination Protocol Length
Info<o:p></o:p></p>
<p class="MsoNormal"> 17 12:12:01.339034
10.10.12.70 10.10.14.71 SIP 667
Status: 302 Server Redirect |
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Frame 17: 667 bytes on wire (5336 bits),
667 bytes captured (5336 bits)<o:p></o:p></p>
<p class="MsoNormal">Ethernet II, Src: bb:bb:bb:bb:bb:bb
(bb:bb:bb:bb:bb:bb), Dst: aa:aa:aa:aa:aa:aa
(aa:aa:aa:aa:aa:aa)<o:p></o:p></p>
<p class="MsoNormal">Internet Protocol Version 4, Src:
10.10.12.70, Dst: 10.10.14.71<o:p></o:p></p>
<p class="MsoNormal">User Datagram Protocol, Src Port: 5070, Dst
Port: 5060<o:p></o:p></p>
<p class="MsoNormal">Session Initiation Protocol (302)<o:p></o:p></p>
<p class="MsoNormal"> Status-Line: SIP/2.0 302 Server
Redirect<o:p></o:p></p>
<p class="MsoNormal"> Message Header<o:p></o:p></p>
<p class="MsoNormal"> From: <a
href="sip:+4478341xxxxx@151.x.xxx.x;user=phone"
moz-do-not-send="true">
sip:+4478341xxxxx@151.x.xxx.x;user=phone</a>;tag=BN1699364667-1-1699963921-901707368<o:p></o:p></p>
<p class="MsoNormal"> To: <a
href="sip:080001xxxxx@149.x.xxx.xx;user=phone"
moz-do-not-send="true">
sip:080001xxxxx@149.x.xxx.xx;user=phone</a>;tag=5d8f.a1daebfe0f15d4035f73e92edd390da9<o:p></o:p></p>
<p class="MsoNormal"> Call-ID: <a
href="mailto:55182316_87520217@151.x.xxx.x"
moz-do-not-send="true">
55182316_87520217@151.x.xxx.x</a><o:p></o:p></p>
<p class="MsoNormal"> [Generated Call-ID: <a
href="mailto:55182316_87520217@151.x.xxx.x"
moz-do-not-send="true">
55182316_87520217@151.x.xxx.x</a>]<o:p></o:p></p>
<p class="MsoNormal"> CSeq: 706035 INVITE<o:p></o:p></p>
<p class="MsoNormal"> Via: SIP/2.0/UDP
10.10.14.71:5060;branch=z9hG4bK-34260abf-94a28-2449afc3-7f0920d0abc8<o:p></o:p></p>
<p class="MsoNormal"> Via: SIP/2.0/UDP
149.x.xxx.xx:5060;received=151.x.xxx.x;rport=5060;branch=z9hG4bK1699364667<o:p></o:p></p>
<p class="MsoNormal"> Via: SIP/2.0/UDP
151.x.xxx.x:5060;branch=z9hG4bK0aB220722fa7bfe603d<o:p></o:p></p>
<p class="MsoNormal"> Contact:
<<a class="moz-txt-link-freetext" href="sip:33557719673@10.10.4.77:5060">sip:33557719673@10.10.4.77:5060</a><o:p></o:p></p>
<p class="MsoNormal"> >Server: OpenSIPS (3.2.13
(x86_64/linux))<o:p></o:p></p>
<p class="MsoNormal"> [Expert Info (Note/Undecoded):
Unrecognised SIP header (>server)]<o:p></o:p></p>
<p class="MsoNormal"> [Unrecognised SIP header
(>server)]<o:p></o:p></p>
<p class="MsoNormal"> [Severity level: Note]<o:p></o:p></p>
<p class="MsoNormal"> [Group: Undecoded]<o:p></o:p></p>
<p class="MsoNormal"> Content-Length: 0<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Whether this is related or not, I cannot
say, but thought I would include it in any case.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Many Thanks,<o:p></o:p></p>
<p class="MsoNormal">Ben<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span
style="mso-ligatures:none;mso-fareast-language:EN-GB"
lang="EN-US">From:</span></b><span
style="mso-ligatures:none;mso-fareast-language:EN-GB"
lang="EN-US"> Bogdan-Andrei Iancu
<a class="moz-txt-link-rfc2396E" href="mailto:bogdan@opensips.org"><bogdan@opensips.org></a>
<br>
<b>Sent:</b> Wednesday, November 15, 2023 7:30 AM<br>
<b>To:</b> OpenSIPS users mailling list
<a class="moz-txt-link-rfc2396E" href="mailto:users@lists.opensips.org"><users@lists.opensips.org></a>; Ben Bliss
<a class="moz-txt-link-rfc2396E" href="mailto:ben.bliss@telxl.com"><ben.bliss@telxl.com></a><br>
<b>Subject:</b> Re: [OpenSIPS-Users] Odd URI formatting
issue when using Exec to return a variable<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>CAUTION: This email originated from outside your
organization. Exercise caution when opening attachments or
clicking links, especially from unknown senders.<o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier
New"">Hi Ben,<br>
<br>
Could you post the xlog output and the resulting 302 ? Also
be sure you are using the latest 3.2 version - please post
the `opensips -V` here.<br>
<br>
Regards,<br>
<br>
</span><o:p></o:p></p>
<pre>Bogdan-Andrei Iancu<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>OpenSIPS Founder and Developer<o:p></o:p></pre>
<pre> <a href="https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.opensips-solutions.com&c=E,1,n_ThlRNU3i-MoIo_dhzoLTuWEvWUOlYVNSDoisTDDrwzbpcftjAa4w_2PyxMOisnPvCBiGpAygCZjMhqUzFW_eo3M1DZs60QBAwbpZYM6fdEYEdZt7_0&typo=1" moz-do-not-send="true">https://www.opensips-solutions.com</a><o:p></o:p></pre>
<pre> <a href="https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.siphub.com&c=E,1,FaWC5zmYssK-iGLeBMdcpIfqOyqXzRepdKxkoIroZfSn0rDpGcOHq3E-rAA6pLhypuKjMgc8st1DlBDvpaiolXtmHYeW9PIxKMk9l27g6Jmoso3H5n9a6tC2bOqe&typo=1" moz-do-not-send="true">https://www.siphub.com</a><o:p></o:p></pre>
<div>
<p class="MsoNormal">On 11/14/23 4:00 PM, Ben Bliss wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<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/"
moz-do-not-send="true">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>
<p class="MsoNormal"><span
style="mso-ligatures:none;mso-fareast-language:EN-GB"><br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>Users mailing list<o:p></o:p></pre>
<pre><a href="mailto:Users@lists.opensips.org" moz-do-not-send="true">Users@lists.opensips.org</a><o:p></o:p></pre>
<pre><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" moz-do-not-send="true">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><span
style="mso-ligatures:none;mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></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>