I'm using Kamailio 3.1I have a custom routing statement called MYROUTE which is placed like this:
route {
...
route (MYROUTE);
route (RELAY);
}
Inside MYROUTE I do some custom SQL checking that basically selects the least cost provider for the ongoing call. The MYROUTE routine sets the $rU, $rd and $rp variables in case a provider has been found for the dialed number or fails with Sip code 404.
All this works perfectly, except in my database I also have an alternate provider that I only wish to use as backup in case the main provider returns a 5XX code.
How do I get Kamailio to try the second provider after the first one failed ?
So far I've tried setting up a t_on_failure() command & routine that picks up the backup provider from the database and sets $rU, $rd & $rp variables. This works fine too except the call is never forwarded to the second provider. It stops with this error I believe:
0(11460) DEBUG: <core> [parser/msg_parser.c:167]: get_hdr_field: cseq <CSeq>: <1> <ACK>
0(11460) DEBUG: <core> [parser/msg_parser.c:201]: DEBUG: get_hdr_body : content_length=0
0(11460) DEBUG: <core> [parser/msg_parser.c:103]: found end of header
0(11460) DEBUG: maxfwd [mf_funcs.c:66]: max_forwards header not found!
0(11460) DEBUG: <core> [parser/parse_to.c:174]: DEBUG: add_param: tag=4a2aab60
0(11460) DEBUG: <core> [parser/parse_to.c:803]: end of header reached, state=29
0(11460) DEBUG: siputils [checks.c:76]: totag found
0(11460) DEBUG: rr [loose.c:108]: No Route headers found
0(11460) DEBUG: rr [loose.c:910]: There is no Route HF
I believe the problem is that t_on_failure() does not keep all the proper data associated with the call and that's why it fails Maybe t_on_failure isn't the right command to use here after all (?).
So to resume. Here's what I wish to achieve:
1. Call comes through
2. Goes through MYROUTE where a provider is selected
3. Call is attempted through provider found in #2
4. If call fails , select another provider
5. Call is attempted through provider found in #4
Thanks!