[OpenSIPS-Users] trying to rewriteuri to the value of a variable

Dave Singer dave.singer at wideideas.com
Mon Feb 7 19:27:47 CET 2011


Last week I ran into a similar thing with force_socket(). I was trying
to setup to force it out the second IP on the server and have it
generic for two load balanced servers. I did if ( $Ri == "<server 1's
IP>" ) { force_socket("<server 1's second IP>:5060"); } else {
force_socket("server 2's IP>:5060"); }
Interesting that config file check didn't catch the "error" but when I
started it up for "real" it displayed an error and stopped running.
It is a good thing I had my 2nd level config check implemented on
there where I run it listening on a local interface and dummy port. It
failed that test so it didn't actually restart opensips. (FYI: I
poseted my init.d script a while back)
It took me a while to realize $fs was there and made things sooooooo
much better.

We need to document for the functions like rewriteuri where there are
alternative variables like $ru, $du, $fs that that the variables are
available and the difference between the two. Maybe even depricate the
less feature-full functions unless there is an advantage like
performance.

Dave

On Sun, Feb 6, 2011 at 7:01 PM, Duane Larson <duane.larson at gmail.com> wrote:
> I don't know that its mentioned in the documentation, but I ran across the
> same issue and remembered finding something about it by searching nabble's
> opensips part.
>
> Its one of those things you chalk up to experience.
>
> Sent from Droid
>
> On Feb 6, 2011 8:54 PM, "Nigel Daniels" <nigel.daniels at connectandsell.com>
> wrote:
>> that seems to be working, thanks alot ! clearly I need to re-read the docs
>>
>> On Sun, Feb 6, 2011 at 6:48 PM, Dave Singer
>> <dave.singer at wideideas.com>wrote:
>>
>>> Isn't
>>> $var(my_uri) = "555 at example.com";
>>> $ru = "sip:" + $var(my_ruri);
>>> the same as
>>> rewriteuri("sip:555 at example.com");
>>> just that using $ru you can use it just like assigning to other vars
>>> like you are doing.
>>>
>>>
>>> On Sun, Feb 6, 2011 at 6:36 PM, Duane Larson <duane.larson at gmail.com>
>>> wrote:
>>> > Avpops
>>> >
>>> > Sent from Droid
>>> >
>>> > On Feb 6, 2011 8:34 PM, "Nigel Daniels" <
>>> nigel.daniels at connectandsell.com>
>>> > wrote:
>>> >> the problem is that rewriteuri() does not support variables is there
>>> >> any
>>> >> alternative to rewriteuri() for changing the uri
>>> >>
>>> >> On Sun, Feb 6, 2011 at 6:26 PM, Tyler Merritt <tyler at fonality.com>
>>> wrote:
>>> >>
>>> >>> I do this as well:
>>> >>>
>>> >>> $var(origFromNumber) = $(re{uri.user});
>>> >>> $var(finalFromURI) = "sip:81" + $(var(origFromNumber){s.substr,1,0})
>>> >>> +
>>> >>> "@"
>>> >>> + $fd;
>>> >>>
>>> >>> This works fine for me. Takes what is essentially a DID and formats
>>> >>> it
>>> to
>>> >>> a SIP PEER string as per the carrier.
>>> >>>
>>> >>> You say that var(z) prints correctly in the logs, but according to
>>> >>> the
>>> >>> parser it's not a legit URI. It may just be that your upstream routes
>>> >>> don't
>>> >>> recognize this format.
>>> >>>
>>> >>> We use the usr_loc and db_aliases in order to match the URI up with a
>>> >>> destination - have you ensured that there is a valid destination for
>>> this
>>> >>> SIP URI?
>>> >>>
>>> >>> _______________________________________________
>>> >>> Users mailing list
>>> >>> Users at lists.opensips.org
>>> >>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>> >>>
>>> >>>
>>> >>
>>> >>
>>> >> --
>>> >> Nigel Daniels
>>> >> Network & Systems Administrator
>>> >> ConnectAndSell inc.
>>> >> (650)-533-2542 <+16505332542>
>>> >
>>> > _______________________________________________
>>> > Users mailing list
>>> > Users at lists.opensips.org
>>> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>> >
>>> >
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>
>>
>>
>> --
>> Nigel Daniels
>> Network & Systems Administrator
>> ConnectAndSell inc.
>> (650)-533-2542
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>



More information about the Users mailing list