Hi, 
I'm not sure if I understood correctly, however, it seems like if UserB is dialed then send call to FreeSWITCH in parallel to doing an http_async_query ; once the http query returns a response then send call to that response.

If I'm correct then you need to make use of branch_route. 

route{
...

    append_branch("sip:prompt-tone@freeswitch");
    t_on_branch("api_query");
    route(RELAY);
}


Then create the branch route "api_query" and in there execute your HTTP async query. 
branch_route[api_query]{         
         if($rU != "freeswitch") 
             route(http_aysnc_things);
}

route[http_async_things]{
   Code example from here: https://www.kamailio.org/docs/modules/5.1.x/modules/http_async_client.html#http_async_client.f.http_async_query
}

route[HTTP_REPLY] {
    if ($http_ok) {
        xlog("L_INFO", "route[HTTP_REPLY]: status $http_rs body: $http_rb\n");
        # Assuming the HTTP server replies with a SIP URI
        $ru = $http_rb;
        route(RELAY);
    } else {
        xlog("L_INFO", "route[HTTP_REPLY]: error  $http_err)\n");
    }
}

Thats just my idea , the code might have syntax issues so correct accordingly. If above works then it should do both ringing and the API query in parallel. As I see it you're trying to append_branch and then doing a t_newtran->HTTP ASYNC query, causing the whole blockage and that explains if you remove the last 4 line it works.

Regards,
Sammy




On Fri, Dec 1, 2017 at 3:14 AM, 赵国杰 <zhaoguojie2010@163.com> wrote:
Hello,
      I forgot to add route(RELAY) after the append_branch(). This brings another problem. Say the original INVITE is from A to B, what I want is:
          1. fork 1 more INVITE to freeswitch 
          2. discard the original A to B INVITE and wait for the http_async_query returns. When returns, the final destiation is determined, say C. Then send the INVITE to C. 

     However, after append_branch(), then original INVITE is sent to B anyway. How do I block the A to B INVITE?

Thanks

At 2017-12-01 15:13:10, "赵国杰" <zhaoguojie2010@163.com> wrote:
Hello Sammy,
     Yes, I want the kamailio to play ring-back music immediately after it receive the INVITE.  My plan is to append a branch to freeswitch and let freeswitch to play the music. The problem is append_branch() does not work in the following context:

if(is_method("INVITE")) {
                append_branch("sip:prompt-tone@freeswitch");
                xlog("append branch");
                t_newtran();
                $http_req(hdr) = "Content-Type: application/json";
                $http_req(body) = $_s({"cmuid": "$var(cmuid)"});
                http_async_query("http://127.0.0.1:8080", "HTTP_REPLY");
}

if I remove the last 4 lines everything works fine. Otherwise, no forked INVITE will be sent to freeswitch. Unfortunately, I need the http_async_query to find the proper callee. Any suggestions?

Thanks

At 2017-11-30 23:49:59, "SamyGo" <govoiper@gmail.com> wrote:
Hi,
While Brandon is right, you can do absolutely do that but w/o any SDP or progress media in there. I'd ask why you want to do that! If you want to feed some ring-back music I'd advise you to append a branch to a media-server like asterisk and then let that do it for you.

So here's one way of doing that.

if(is_method("INVITE")){
         append_branch("sip:183@192.168.1.5:5060");
...
}

where IP is of asterisk and dialplan is configured to provider Progress() with media. 

Again, it depends on why you want it?

Regards,
Sammy

On Wed, Nov 29, 2017 at 11:13 PM, Brandon Armstead <brandon@cryy.com> wrote:
if(is_method(“INVITE”)){ .....

sl_send_reply(“183”, “Ringing”); ....

}

On Wed, Nov 29, 2017 at 6:44 PM 赵国杰 <zhaoguojie2010@163.com> wrote:
Hello guys, 
     Is it possible for kamailio to initiate a 183 to caller?

Thanks 


 

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Sent from Gmail Mobile

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users




 



 


_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users