hi all,
i need to use the dispatcher module to route (load-balanced) an incoming SIP request to one of my bunch of asterisk machines. openser (1.1.0, the only one that implements the dispatcher as i need it) is also supposed to translate from TCP (the protocol that my peer gateway uses) to UDP (the only protocol that asterisk knows - snip).
my attempt was this:
# routing INVITE and CANCEL messages received from the gateway to Asterisk if (uri=~"^sip:+1[0-9]+@xx.xx.xx.xx") { t_on_failure("2"); if ((method=="INVITE") || (method=="CANCEL")) { ds_select_dst("1", "0"); t_relay("udp:$dd:5061"); return; } }
note that t_relay() must change the protocol type and set a non-default port number. the problem is that the $dd pseudovariable in t_relay() is not parsed, i actually get an error at openser startup:
Jul 11 14:43:31 davinci /usr/local/sbin/openser[16906]: ERROR: mk_proxy: could not resolve hostname: "$dd" Jul 11 14:43:31 davinci /usr/local/sbin/openser[16906]: ERROR:tm:fixup_phostport2proxy: failed to resolve <$dd> Jul 11 14:43:31 davinci /usr/local/sbin/openser[16906]: ERROR: fix_actions: fixing failed (code=-478) at cfg line 119
anybody has any idea about how can i either: (A) set the preferred protocol and destination port for the transaction, then call t_relay() with no arguments, OR (B) capture the destination domain name selected by the dispatcher in a variable, append "udp:" in front of it and ":5061" at the end, and feed it as argument to t_relay().
a hint would be great, a few lines of code would be even better ;) since i have some trouble locating the documentation for the core functions.
thanks!
Radu M.
you can include the port in the dispatcher.list file ie 1 sip:somehost:someport 2 sip:someotherhost:someotherport
As for the TCP->UDP bit you could include the "uri.so" module and try
ds_select_domain("1", "0"); add_uri_param("transport=UDP"); t_relay();
The docs say that the add_uri_param will only work from the ROUTE function, so handling gateway failover could be an issue if you can't do it from the FAILURE_ROUTE thing...
You could also try "avpops.so" module and try
ds_select_domain("1", "0"); avp_printf("$avp(i:123)", "$ru;transport=UDP" ); avp_pushto("$ru", "$avp(i:123)" ); t_relay();
and similar in your FAILURE_ROUTE block.
In theory (??) you should not have to do a ds_select_domain() with the CANCEL branch as the destination should already be known to OpenSER (as it routed the INVITE), so you should just be able to t_relay() it...
I don't have a TCP SIP initiator to test any of this, but perhaps it will help...
Perhaps a feature request for the dispatcher module to support transport types as well??
On Tue, 2006-07-11 at 13:49 -0700, Radu Maierean wrote:
hi all,
i need to use the dispatcher module to route (load-balanced) an incoming SIP request to one of my bunch of asterisk machines. openser (1.1.0, the only one that implements the dispatcher as i need it) is also supposed to translate from TCP (the protocol that my peer gateway uses) to UDP (the only protocol that asterisk knows - snip).
my attempt was this:
# routing INVITE and CANCEL messages received from the gateway to Asterisk if (uri=~"^sip:+1[0-9]+@xx.xx.xx.xx") { t_on_failure("2"); if ((method=="INVITE") || (method=="CANCEL")) { ds_select_dst("1", "0"); t_relay("udp:$dd:5061"); return; } }
Hello,
On 07/11/06 23:49, Radu Maierean wrote:
hi all,
i need to use the dispatcher module to route (load-balanced) an incoming SIP request to one of my bunch of asterisk machines. openser (1.1.0, the only one that implements the dispatcher as i need it) is also supposed to translate from TCP (the protocol that my peer gateway uses) to UDP (the only protocol that asterisk knows - snip).
my attempt was this:
# routing INVITE and CANCEL messages received from the gateway to Asterisk if (uri=~"^sip:+1[0-9]+@xx.xx.xx.xx") { t_on_failure("2"); if ((method=="INVITE") || (method=="CANCEL")) { ds_select_dst("1", "0"); t_relay("udp:$dd:5061"); return; } }
note that t_relay() must change the protocol type and set a non-default port number. the problem is that the $dd pseudovariable in t_relay() is not parsed, i actually get an error at openser startup:
t_relay("dst") does not support pseudo-variables - it compiles the destination address (dns, ...) at startup. So you have to use the dst_uri (outbound address) field. Try:
ds_select_dst("1", "0"); avp_printf("$avp(i:100)", "sip:$dd:5061;transport=udp"); avp_pushto("$duri", "$avp(i:100)"); t_relay();
Jul 11 14:43:31 davinci /usr/local/sbin/openser[16906]: ERROR: mk_proxy: could not resolve hostname: "$dd" Jul 11 14:43:31 davinci /usr/local/sbin/openser[16906]: ERROR:tm:fixup_phostport2proxy: failed to resolve <$dd> Jul 11 14:43:31 davinci /usr/local/sbin/openser[16906]: ERROR: fix_actions: fixing failed (code=-478) at cfg line 119
anybody has any idea about how can i either: (A) set the preferred protocol and destination port for the transaction, then call t_relay() with no arguments, OR (B) capture the destination domain name selected by the dispatcher in a variable, append "udp:" in front of it and ":5061" at the end, and feed it as argument to t_relay().
a hint would be great, a few lines of code would be even better ;) since i have some trouble locating the documentation for the core functions.
http://openser.org/dokuwiki/doku.php?id=openser_core_cookbook http://www.openser.org/docs/modules/1.1.x/
Cheers, Daniel
thanks!
Radu M.
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users