<div dir="ltr">Hi,<div>I analyzed and reproduced your issue and here's my conclusions:</div><div><br></div><div>1) in your scenario TSILO module is not involved nor needed. TSILO implements "deferred" parallel forking while, in your case, what you are trying to implement is serial forking with chained transaction suspensions. You can see in your logs that TSILO's functions are called just to store the transaction, never to append to it new branches.</div><div>2) Kamailio is not currently able to suspend a transaction which already received a final reply. As a proof of this in your logs, at row 6483, we can see that Kamailio sent out a 500 reply. In your case the fact that you are able to resume somehow the transaction is a race condition due to the fact that the REGISTER for the 2nd r-uri is coming when the transaction has still not been deleted. I could reproduce this exact scenario. I opened a PR with a fix (<a href="https://github.com/kamailio/kamailio/pull/955">https://github.com/kamailio/kamailio/pull/955</a>) which I successfully tested. Let's wait for Daniel's feedback. </div><div>3) The problem of the new r-uri not taken in count while resuming the transaction is due to the fact that, in a failure route we are working on a copy of the original message and, the changes to it are not ported to the shm message clone that's used later for resuming the transaction. I don't have an easy solution for this, maybe Daniel can help :) Anyway I have a workaround for this: set and avp in the failure route with the new ruri you whish to use and use it in the resume route to set $ru for the message. Somethig like:</div><div><br></div><div>route[INVRESUME] {<br></div><div>    ....<br>    if (is_avp_set("$avp(ru)")) <br>               $ru = $avp(ru);<br>  .....<br></div><div>}</div><div><br></div><div>With the above patch on tm and this workaround I could successfully implement your scenario.</div><div><br></div><div>Best regards,</div><div><br></div><div>Federico</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 24, 2017 at 10:16 AM, Tomas Zanet <span dir="ltr"><<a href="mailto:tzanet@came.com" target="_blank">tzanet@came.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Federico, sorry you’re right about log level.<br>
Kamailio was running with right debug level but my syslog was configured to split log messages based on level so all logs with debug went to another file called debug.<br>
I reconfigured syslog, please see the new attached file.<br>
<br>
I should have found the log lines where there's $ru overwriting, should be the following log lines:<br>
2017-01-24T08:39:30+00:00 server-xip-99 /usr/local/sbin/kamailio[<wbr>26021]: ERROR: <script>: resuming trasaction [58698:23306391] 00......02181 58698:23306391)sip:<wbr>7ffe85fb456f629b......net<br>
2017-01-24T08:39:30+00:00 server-xip-99 /usr/local/sbin/kamailio[<wbr>26021]: ERROR: *** cfgtrace:request_route=[<wbr>PUSHJOIN] c=[/usr/local/etc/kamailio/<wbr>kamailio.cfg] l=1011 a=27 n=t_continue<br>
2017-01-24T08:39:30+00:00 server-xip-99 /usr/local/sbin/kamailio[<wbr>26021]: DEBUG: tm [t_lookup.c:1574]: t_lookup_ident(): DEBUG: t_lookup_ident: transaction found<br>
2017-01-24T08:39:30+00:00 server-xip-99 /usr/local/sbin/kamailio[<wbr>26021]: ERROR: *** cfgtrace:failure_route=[<wbr>INVRESUME] c=[/usr/local/etc/kamailio/<wbr>kamailio.cfg] l=1016 a=26 n=xlog<br>
2017-01-24T08:39:30+00:00 server-xip-99 /usr/local/sbin/kamailio[<wbr>26021]: ALERT: <script>: Invite remused for sip:00......00000@<wbr>7FFE85FB456F629B........net<br>
2017-01-24T08:39:30+00:00 server-xip-99 /usr/local/sbin/kamailio[<wbr>26021]: ERROR: *** cfgtrace:failure_route=[<wbr>INVRESUME] c=[/usr/local/etc/kamailio/<wbr>kamailio.cfg] l=1017 a=25 n=lookup<br>
<br>
In fact, after resuming the transaction with right 2181 account, it's called  t_continue and then t_lookup_ident funcs which says " transaction found", but maybe the transaction is not the right one...<br>
But I don't know why that happens.<br>
<br>
I also tried to add append_branch() function as you suggested but with no luck…<br>
<br>
I don’t know why but when I copied and pasted the code statements, all branches disappeared…but they are in the Kamailio.cfg....<br>
Let me retry changing email body text format.<br>
<div><div class="h5"># USER location service<br>
route[LOCATION] {<br>
<br>
#!ifdef WITH_SPEEDDIAL<br>
        # search for short dialing - 2-digit extension<br>
        if($rU=~"^[0-9][0-9]$")<br>
                if(sd_lookup("speed_dial"))<br>
                        route(SIPOUT);<br>
#!endif<br>
<br>
#!ifdef WITH_ALIASDB<br>
        # search in DB-based aliases<br>
        if(alias_db_lookup("dbaliases"<wbr>))<br>
                route(SIPOUT);<br>
#!endif<br>
#!ifdef WITH_FORK<br>
        if($rU == "9999") {<br>
                route(FORK);<br>
        }<br>
#!endif<br>
<br>
#!ifdef WITH_PDT<br>
        xdbg("before pdt $rU\n");<br>
        #prefix2domain("0", "1");<br>
        xdbg("after pdt $rU\n");<br>
#!endif<br>
        #Check if domains match<br>
<br>
        if($fd != $rd) {<br>
                xdbg("From domain $fd does not match request uri domain $rd\n");<br>
                send_reply("488", "Not Accetable Here");<br>
                exit;<br>
        }<br>
<br>
        #$rd = $td<br>
        $avp(oexten) = $rU;<br>
        if (!lookup("location")) {<br>
                $var(rc) = $rc;<br>
                t_newtran();<br>
                switch ($var(rc)) {<br>
                        case -1:<br>
                        case -3:<br>
                                xlog("L_ALERT","ALERT: User not found\n");<br>
                                if (isflagset(FLT_ASTERISK_TRY)) {<br>
                                        # Try calling with PUSH KIT<br>
                                        send_reply("404", "Not Found");<br>
                                } else {<br>
</div></div>                                        # User not found, check if is an app, then call it with pushkit<br>
                                        if($(rU{s.substr,0,6})=="<wbr>007001") {<br>
<span class="">                                                xlog("L_ALERT","ALERT: Trying calling $ru with PUSUH KIT\n");<br>
                                                # device token check missing<br>
                                                route(SUSPEND);<br>
                                                route(SENDPUSH);<br>
                                        } else {<br>
                                                setflag(FLT_ASTERISK_TRY);<br>
                                                route(ASTERISK);<br>
                                        }<br>
                                }<br>
                                exit;<br>
                        case -2:<br>
                                send_reply("405", "Method Not Allowed");<br>
                                exit;<br>
                }<br>
        }<br>
<br>
        # when routing via usrloc, log the missed calls also<br>
        if (is_method("INVITE"))<br>
                setflag(FLT_ACCMISSED);<br>
<br>
        route(RELAY);<br>
        route(STORETRAN);<br>
        exit;<br>
}<br>
<br>
route[STORETRAN] {<br>
        ts_store();<br>
        $sht(vtp=>stored::$rU) = 1;<br>
        xlog("L_ALERT", "stored transaction [$T(id_index):$T(id_label)] $fU => $rU\n");<br>
}<br>
<br>
</span># manage failure routing cases<br>
failure_route[MANAGE_FAILURE] {<br>
        xlog("L_ALERT", "MANAGE_FAILURE $rm $ru\n");<br>
        route(NATMANAGE);<br>
<br>
        if (t_is_canceled()) {<br>
                xlog("L_ALERT", "MANAGE_FAILURE CANCELED\n");<br>
<span class="">                exit;<br>
        }<br>
<br>
#!ifdef WITH_BLOCK3XX<br>
        # block call redirect based on 3xx replies.<br>
        if (t_check_status("3[0-9][0-9]")<wbr>) {<br>
                t_reply("404","Not found");<br>
                exit;<br>
        }<br>
#!endif<br>
<br>
       if (is_avp_set("$avp(group_<wbr>members_db)")) {<br>
                $ru ="sip:"+$avp(group_members_db)<wbr>+"@"+$fd;<br>
</span>                #append_branch();<br>
                #$ru = $avp(group_members);<br>
                $avp(group_members_db) = $null;<br>
                t_on_failure("MANAGE_FAILURE")<wbr>;<br>
        xlog("L_ALERT", "MANAGE_FAILURE $rm $ru $tu $fu\n");<br>
                route(STORETRAN);<br>
                route(LOCATION);<br>
                exit;<br>
<span class="">        }<br>
}<br>
<br>
<br>
<br>
Tomas Zanet<br>
Software Design Department<br>
<a href="mailto:tzanet@came.com">tzanet@came.com</a><br>
</span>CAME S.p.A.<br>
<span class=""><br>
<br>
Da: sr-users [mailto:<a href="mailto:sr-users-bounces@lists.sip-router.org">sr-users-bounces@<wbr>lists.sip-router.org</a>] Per conto di Federico Cabiddu<br>
</span>Inviato: martedì 24 gennaio 2017 07:57<br>
<span class="">A: Kamailio (SER) - Users Mailing List <<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><wbr>><br>
</span>Oggetto: Re: [SR-Users] R: serial forking calls using TSILO<br>
<div class="HOEnZb"><div class="h5"><br>
Hi,<br>
the logs are not at level 3 (there are no DEBUG messages). Could you please repeat the test?<br>
In the meanwhile can you also try adding a branch after setting the r-uri in the failure route?<br>
<br>
$ru ="sip:"+$avp(group_members_db)<wbr>+"@"+$fd;<br>
append_branch();<br>
<br>
I've also noticed that, in the failure route, the statements after<br>
<br>
if (is_avp_set("$avp(group_<wbr>members_db)"))<br>
<br>
are not enclosed in braces, is this intentional?<br>
<br>
Regards,<br>
<br>
Federico<br>
<br>
On Mon, Jan 23, 2017 at 10:01 AM, Tomas Zanet <<a href="mailto:tzanet@came.com">tzanet@came.com</a>> wrote:<br>
Hi, please find below what you requested.<br>
<br>
@Daniel: yes, I did ts_store() after relaying for both hops, but for the second call which should call account2, $ru is overwritten to account1 after t_continue<br>
<br>
@Federico: as you requested, here is my route[LOCATION] and please the attached Kamailio log.<br>
# USER location service<br>
route[LOCATION]<br>
<br>
#!ifdef WITH_SPEEDDIAL<br>
        # search for short dialing - 2-digit extension<br>
        if($rU=~"^[0-9][0-9]$")<br>
                if(sd_lookup("speed_dial"))<br>
                        route(SIPOUT);<br>
#!endif<br>
<br>
#!ifdef WITH_ALIASDB<br>
        # search in DB-based aliases<br>
        if(alias_db_lookup("dbaliases"<wbr>))<br>
                route(SIPOUT);<br>
#!endif<br>
<br>
#!ifdef WITH_FORK<br>
        if($rU == "9999")<br>
                route(FORK);<br>
<br>
#!endif<br>
<br>
#!ifdef WITH_PDT<br>
        xdbg("before pdt $rU\n");<br>
        #prefix2domain("0", "1");<br>
        xdbg("after pdt $rU\n");<br>
#!endif<br>
        #Check if domains match<br>
<br>
        if($fd != $rd)<br>
                xdbg("From domain $fd does not match request uri domain $rd\n");<br>
                send_reply("488", "Not Accetable Here");<br>
                exit;<br>
<br>
<br>
        #$rd = $td<br>
        $avp(oexten) = $rU;<br>
        if (!lookup("location"))<br>
                $var(rc) = $rc;<br>
                t_newtran();<br>
                switch ($var(rc))<br>
                        case -1:<br>
                        case -3:<br>
                                xlog("L_ALERT","ALERT: User not found\n");<br>
                                if (isflagset(FLT_ASTERISK_TRY))<br>
                                        # Try calling with PUSH KIT<br>
                                        send_reply("404", "Not Found");<br>
                                 else<br>
                                        # User not found, check if is an app based on uri prefix, then call it with pushkit<br>
                                        if($(rUs.substr,0,6)=="007001"<wbr>)<br>
                                                xlog("L_ALERT","ALERT: Trying calling $ru with PUSUH KIT\n");<br>
                                                # device token check missing<br>
                                                route(SUSPEND);<br>
                                                route(SENDPUSH);<br>
                                         else<br>
                                                setflag(FLT_ASTERISK_TRY);<br>
                                                route(ASTERISK);<br>
<br>
<br>
      exit;<br>
                        case -2:<br>
                                send_reply("405", "Method Not Allowed");<br>
                                exit;<br>
<br>
<br>
<br>
        # when routing via usrloc, log the missed calls also<br>
        if (is_method("INVITE"))<br>
                setflag(FLT_ACCMISSED);<br>
<br>
        route(RELAY);<br>
        route(STORETRAN);<br>
        exit;<br>
<br>
<br>
route[STORETRAN]<br>
        ts_store();<br>
        $sht(vtp=>stored::$rU) = 1;<br>
        xlog("L_ALERT", "stored transaction [$T(id_index):$T(id_label)] $fU => $rU\n");<br>
<br>
<br>
<br>
Thanks to both,<br>
Regards,<br>
T.<br>
<br>
Da: sr-users [mailto:<a href="mailto:sr-users-bounces@lists.sip-router.org">sr-users-bounces@<wbr>lists.sip-router.org</a>] Per conto di Federico Cabiddu<br>
Inviato: domenica 22 gennaio 2017 16:24<br>
A: Kamailio (SER) - Users Mailing List <<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><wbr>><br>
Oggetto: Re: [SR-Users] serial forking calls using TSILO<br>
<br>
Hi,<br>
could you please provide the LOCATION route and the Kamailio's log at level 3?<br>
Thank you.<br>
<br>
Regards,<br>
<br>
Federico<br>
<br>
On Fri, Jan 20, 2017 at 11:05 AM, Tomas Zanet <<a href="mailto:tzanet@came.com">tzanet@came.com</a>> wrote:<br>
Hello,<br>
I’m using Kamailio 4.4.4 with TSILO module in order to support Push Notifications used by our voip app on Apple ios10.<br>
So far, everything works fine:  Kamailio can get an incoming call, suspend it, then send push notification with an external script, receive a new app registration and then call it after resuming the invite.<br>
To do so, thanks to Mr, Cabiddu, I used all the functions described here<br>
<a href="http://www.kamailio.org/events/2015-KamailioWorld/Day2/20-Federico.Cabiddu-Kamailio-In-A-Mobile-World.pdf" rel="noreferrer" target="_blank">http://www.kamailio.org/<wbr>events/2015-KamailioWorld/<wbr>Day2/20-Federico.Cabiddu-<wbr>Kamailio-In-A-Mobile-World.pdf</a><br>
<br>
<br>
Right now, I would like to support serial forking calls using push notification because it was already supported with legacy voip.<br>
To do so, I used failure_route function where, after getting the call destinations and setting them into an avp, I set the new SIP request uri $ru.<br>
Here is my failure_route:<br>
failure_route[MANAGE_FAILURE]<br>
        route(NATMANAGE);<br>
        if (t_is_canceled())<br>
                exit;<br>
<br>
<br>
#!ifdef WITH_BLOCK3XX<br>
        # block call redirect based on 3xx replies.<br>
        if (t_check_status("3[0-9][0-9]")<wbr>)<br>
                t_reply("404","Not found");<br>
                exit;<br>
<br>
#!endif<br>
<br>
       if (is_avp_set("$avp(group_<wbr>members_db)"))<br>
                $ru ="sip:"+$avp(group_members_db)<wbr>+"@"+$fd;<br>
                $avp(group_members_db) = $null;<br>
                route(LOCATION);<br>
                exit;<br>
<br>
<br>
<br>
I am troubleshooting this scenario and this is what I see:<br>
1) Kamailio receives incoming call<br>
2) Suspend it<br>
3) Send Push notification to account1<br>
4) Kamailio receives account1 registration -> INVRESUME route is now called<br>
5) Then call account1<br>
6) Nobody answers the call<br>
7) failure_route[MANAGE_FAILURE] is now called -> set $ru with next sipaccount: account2<br>
8) suspend invite<br>
9) send push notification to account2<br>
10) account2 sends its sip registration -> INVRESUME route is now called<br>
11) Kamailio calls account1 instead of account2 -> this is my issue<br>
<br>
On step 10: despite account2 is registered, I checked it using “kamctl ul show”, the second call is forwarded all'account1 and not to account2.<br>
I also checked the TSILO logs and everything seems ok. Here is the logs:<br>
First call:<br>
      suspended transaction [53945:1648394094] asterisk => account1<br>
      htable key value [53945:1648394094]<br>
      resuming trasaction [53945:1648394094] account1 53945:1648394094)<br>
second call:<br>
      suspended transaction [53945:1648394094] asterisk => account2<br>
      htable key value [53945:1648394094]<br>
      resuming trasaction [53945:1648394094] account2 53945:1648394094)<br>
<br>
In order to find out the issue I put some xlogs, printing $ru value: what I see is the $ru value is set correctly on failure_route but as soon as the t_continue is called, the ru overwritten back to account1<br>
<br>
Can anyone address me to find out the solution?<br>
Thanks in advance<br>
<br>
T.<br>
<br>
<br>
<br>
Tomas Zanet<br>
Software Design Department<br>
<a href="mailto:tzanet@came.com">tzanet@came.com</a><br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br>
<br>
<br>
Tomas Zanet<br>
Software Design Department<br>
<a href="mailto:tzanet@came.com">tzanet@came.com</a><br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br>
</div></div><br>______________________________<wbr>_________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br></blockquote></div><br></div>