[OpenSIPS-Users] Odd URI formatting issue when using Exec to return a variable

Ben Bliss ben.bliss at telxl.com
Tue Nov 14 14:00:56 UTC 2023

I am using Opensips v.3.2 and I am attempting to replicate the 302 redirect outlined on the blog (https://blog.opensips.org/2018/07/05/handling-sip-redirect-requests-in-realtime/), but am running into an odd issue.

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.

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.

If I specify the URI directly within OpenSIPs, then the contact header is then formatted correctly.

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.

The script is setup as follows...

        if ( $si == '' && is_method("INVITE") ) {
                        exec("/usr/local/bin/sbc-route", $tU, $var(out));
                        xlog("Value returned from Re-direct Script is $var(out)");
                        $branch = $var(out);
                        xlog("Target is set as $branch");
                        send_reply(302, "Server Redirect");

Can anyone offer any ideas as to why this may be occurring?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20231114/a0967ab5/attachment.html>

More information about the Users mailing list