[OpenSIPS-Users] dbalias and location lookup branching
Răzvan Crainea
razvan at opensips.org
Wed Sep 27 14:00:19 UTC 2023
No, this is not the solution :).
The problem is you are calling t_relay, but after you evaluate each
branch, it turns out t_relay does not actually relay anything, hence it
returns an error.
The proper way to do this is to figure out whether you do need to send
any branches before calling t_relay() - this means that after the
alias_db_lookup, you can simply call the lookup() function - if that
fails, you should reply with a 404.
But what I am missing is the 500 message - what happened with the call
to the actual extension? Because from your script, it appears you still
want to keep it as a branch, don't you? Isn't that branch properly sent?
Also, the 500 sent to the client is very likely sent by the
sl_reply_error() function - you can replace it with a 404. However, I'd
still refactor everything to handle the branches in the main processing
context, not in the branch route.
My 2cents, best regards,
Răzvan Crainea
OpenSIPS Core Developer / SIPhub CTO
http://www.opensips-solutions.com / https://www.siphub.com
On 9/27/23 13:54, M S wrote:
> Maybe a send_reply(404) after if(!lookup(location)), instead of drop?
>
> On Tue, Sep 26, 2023 at 8:30 PM John Sliney <John.Sliney at lcs.com
> <mailto:John.Sliney at lcs.com>> wrote:
>
> Hi,
>
> I’m currently attempting to take an INVITE from an Asterisk server
> that is requesting an extension number, perform dbalias lookups to
> have extensions turned into sip users (x1000 -> test_hardphone) and
> then do location lookups on those sip users. There can be multiple
> sip users for each extension and multiple locations for each sip user.
>
> Using the code below partially works but when there are no location
> entries for the requested sip user, OpenSIPS returns a 500 and
> prints out “ERROR: t_forward_nonack failed” how can I
> have OpenSIPS instead respond with a 404?
>
> ### CODE ###
>
> modparam("alias_db", "append_branches", 1)
>
> route {
> if ( is_from_gw() ) {
> alias_db_lookup("dbaliases");
> t_on_branch("sip_user_branch");
> }
> route(relay);
> return(0);
> }
>
> branch_route[sip_user_branch] {
> route(lookup_sip_user);
> }
>
> route[lookup_sip_user] {
> if ( ! lookup("location") ) {
> drop();
> }
> }
>
> route[relay] {
> if ( ! t_relay() ) {
> sl_reply_error();
> rtpproxy_unforce();
> return(0);
> }
> }
>
> ### CODE ###
>
> Any help would be appreciated, Thanks
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org <mailto:Users at lists.opensips.org>
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> <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
More information about the Users
mailing list