OK, couple more questions regarding my two options.  So far I can potentially use to_gw_grp(&quot;1&quot;) 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:<br>
<br>1 - to_gw_grp(&quot;1&quot;).  How would I ensure that subsequent in-dialog requests are sent from the same socket as the original INVITE to my ITSP.  <br><br>Asterisk --&gt; INVITE --&gt; KAMAILIO --&gt; (next_gw()/to_gw_grp(&quot;1&quot;)/force_send_socket() --&gt; INVITE --&gt; ITSP<br>
Asterisk --&gt; BYE --&gt; KAMAILIO --&gt; (if(loose_route(){t_relay();}) -- BYE --&gt; ITSP<br><br>How would I call the to_gw_grp(&quot;1&quot;) in this scenario?  Would I just call it after calling loose_route(), but before calling t_relay()?<br>
<br><br>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.<br>
<br>Thanks to everyone for your time and effort here.<br><br>Much appreciated!<br><br>-Geoff<br><br><br><div class="gmail_quote">On Fri, Jun 25, 2010 at 7:45 PM, Iņaki Baz Castillo <span dir="ltr">&lt;<a href="mailto:ibc@aliax.net">ibc@aliax.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">2010/6/25 Geoffrey Mina &lt;<a href="mailto:geoffreymina@gmail.com">geoffreymina@gmail.com</a>&gt;:<br>

<div class="im">&gt; OK, I am running into some errors when starting my script:<br>
&gt;<br>
&gt; if(to_gw(&quot;1&quot;)){<br>
&gt;     force_send_socket(X.X.X.180:5060);<br>
&gt; }else if(to_gw(&quot;3&quot;)){<br>
&gt;     force_send_socket(X.X.X.179:5060);<br>
&gt; }else if(to_gw(&quot;4&quot;)){<br>
&gt;     force_send_socket(X.X.X.189:5060);<br>
&gt; }<br>
&gt;<br>
&gt; Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:<br>
&gt; ERROR:core:pv_parse_spec: bad parameters<br>
&gt; Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:<br>
&gt; ERROR:core:fixup_pvar: parsing of pseudo variable 1 failed!<br>
&gt; Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:<br>
&gt; ERROR:core:fix_actions: fixing failed (code=-1) at cfg line 348<br>
&gt; Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:<br>
&gt; CRITICAL:core:fix_expr: fix_actions error<br>
&gt; Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]:<br>
&gt; ERROR:core:main: failed to fix configuration with err code -1<br>
&gt;<br>
&gt;<br>
&gt; Perhaps I an confused about how the to_gw() function of the LCR module is to<br>
&gt; be used.  In my &quot;gw&quot; table, I have gateways with grp_id 1, 3, and 4.  I am<br>
&gt; assuming that is the value I should be checking for in the to_gw() function,<br>
&gt; but it seems to be expecting a pseudo variable or something.<br>
<br>
</div>Theorically (according to the LCR documentation), &quot;to_gw()&quot; must be<br>
used when processing in-dialog requests. However I&#39;m not sure of the<br>
cause of your error, which is exactly the line 384 in your script?<br>
<br>
Anyhow I suggest you a different approach:<br>
<br>
- Set a different flag for each gw (in LCR &#39;gw&#39; table) depending on<br>
the sending socket that must be used.<br>
- After calling &#39;next_gw()&#39; inspect the value of the gw flags (stored<br>
in a configured AVP) and choose which &#39;force_send_socket()&#39; to use.<br>
<font color="#888888"><br>
<br>
--<br>
Iņaki Baz Castillo<br>
&lt;<a href="mailto:ibc@aliax.net">ibc@aliax.net</a>&gt;<br>
</font></blockquote></div><br>