OK, couple more questions regarding my two options.  So far I can potentially use to_gw_grp("1") OR I can use the flags AVP to store a flag which dictates what my send_socket will be.  Here are my challenges with each:

1 - to_gw_grp("1").  How would I ensure that subsequent in-dialog requests are sent from the same socket as the original INVITE to my ITSP. 

Asterisk --> INVITE --> KAMAILIO --> (next_gw()/to_gw_grp("1")/force_send_socket() --> INVITE --> ITSP
Asterisk --> BYE --> KAMAILIO --> (if(loose_route(){t_relay();}) -- BYE --> ITSP

How would I call the to_gw_grp("1") in this scenario?  Would I just call it after calling loose_route(), but before calling t_relay()?


2 - using AVP flags.  The AVP is only set after the initial call to next_gw(), how would I have access to this flag for in-dialog requests?  I could perhaps store it in a htable with call-id as the key and overwrite the value each time we call next_gw() (in the event there are failures)... just not sure this is the best idea.

Thanks to everyone for your time and effort here.

Much appreciated!

-Geoff


On Fri, Jun 25, 2010 at 7:45 PM, Iņaki Baz Castillo <ibc@aliax.net> wrote:
2010/6/25 Geoffrey Mina <geoffreymina@gmail.com>:
> OK, I am running into some errors when starting my script:
>
> if(to_gw("1")){
>     force_send_socket(X.X.X.180:5060);
> }else if(to_gw("3")){
>     force_send_socket(X.X.X.179:5060);
> }else if(to_gw("4")){
>     force_send_socket(X.X.X.189:5060);
> }
>
> Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:
> ERROR:core:pv_parse_spec: bad parameters
> Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:
> ERROR:core:fixup_pvar: parsing of pseudo variable 1 failed!
> Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:
> ERROR:core:fix_actions: fixing failed (code=-1) at cfg line 348
> Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:
> CRITICAL:core:fix_expr: fix_actions error
> Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:
> ERROR:core:main: failed to fix configuration with err code -1
>
>
> Perhaps I an confused about how the to_gw() function of the LCR module is to
> be used.  In my "gw" table, I have gateways with grp_id 1, 3, and 4.  I am
> assuming that is the value I should be checking for in the to_gw() function,
> but it seems to be expecting a pseudo variable or something.

Theorically (according to the LCR documentation), "to_gw()" must be
used when processing in-dialog requests. However I'm not sure of the
cause of your error, which is exactly the line 384 in your script?

Anyhow I suggest you a different approach:

- Set a different flag for each gw (in LCR 'gw' table) depending on
the sending socket that must be used.
- After calling 'next_gw()' inspect the value of the gw flags (stored
in a configured AVP) and choose which 'force_send_socket()' to use.


--
Iņaki Baz Castillo
<ibc@aliax.net>