I have this scenario
Customer --> Kamailio --> Provider1
The route where l route the call to Provider1 is called route["INCOMING"] and I "arm" the replies and failures to : t_on_reply("INCOMING") and t_on_failure("INCOMING"). Provider1 always replies with a 302 Redirect and in the failure_route["INCOMING'] I have this code:
if (t_check_status("302")) { get_redirects("*"); t_on_branch("REDIRECT_BRANCH"); t_load_contacts(); t_next_contacts(); t_on_failure("SERIAL_FORKING"); t_relay(); exit; }
In the t_on_failure("SERIAL_FORKING") block I do t_relay() as long as there are more contacts to be processed. Lets say I need to try Provider_2 and Provider_3
failure_route["SERIAL_FORKING"] { xlog("L_INFO","mylog: In Failure Route SERIAL_FORKING. Reply [$rs]\n"); if (!t_next_contacts()) { exit; } xlog("L_INFO","mylog: In Failure Route SERIAL_FORKING. Trying next Contact.\n"); t_on_failure("SERIAL_FORKING"); t_relay(); }
I want to use RTPProxy in this scenario and I am using the function rtpproxy_manage() to let kamailio handle it automatically.
RTPProxy ↑ | | Customer --> Kamailio --> Provider1 | | ↓ Provider N
After the 302 response is processed I would like to have the signaling flow "Customer -> Kamailio --> ProviderN" and the RTP flow "Customer --> RTPProxy --> ProviderN"
I have tried inserting the function in several places but can't make it work and what I mean is that sometimes the rtpproxy creates the 1st session and then deletes it as soon as I call it the 2nd time with a message similar to this one (log of rtpproxy) : "INFO:416f20b74a58fb75168175e61b2edece@192.168.1.61:5060:rtpp_cmd_delete_ematch: forcefully deleting session 1 on ports 63502/0". Sometimes the kamailio log shows this message: "ERROR: rtpproxy [rtpproxy.c:2536]: force_rtp_proxy(): incorrect port 0 in reply from rtp proxy"
I think I must call rtpproxy_manage() before I send the INVITE to each of the Providers in the Contact list so they receive a SDP offer with an IP:Port combination provided by the RTPProxy (instead of the ones coming from the Customer). That would be in my route["INCOMING'] Then once Provider_N replies with a 183 with SDP or a 200 OK I would call it again to get a new session to be passed on the reply to my customer. But is the part I am struggling with. Should I add a new reply route inside the failure_route["INCOMING'] only if I am dealing with 302 and do it there ? I am out of ideas guys and any idea is welcome
Hello,
call the rtpproxy_manage() function inside the branch_route, it is a good place always, doing it when you know the request is being forwarded.
Cheers, Daniel
On 12.02.18 19:55, Fabian Borot wrote:
I have this scenario
Customer --> Kamailio --> Provider1
The route where l route the call to Provider1 is called route["INCOMING"] and I "arm" the replies and failures to : t_on_reply("INCOMING") and t_on_failure("INCOMING"). Provider1 always replies with a 302 Redirect and in the failure_route["INCOMING'] I have this code:
if (t_check_status("302")) { get_redirects("*"); t_on_branch("REDIRECT_BRANCH"); t_load_contacts(); t_next_contacts(); t_on_failure("SERIAL_FORKING"); t_relay(); exit; }
In the t_on_failure("SERIAL_FORKING") block I do t_relay() as long as there are more contacts to be processed. Lets say I need to try Provider_2 and Provider_3
failure_route["SERIAL_FORKING"] { xlog("L_INFO","mylog: In Failure Route SERIAL_FORKING. Reply [$rs]\n"); if (!t_next_contacts()) { exit; } xlog("L_INFO","mylog: In Failure Route SERIAL_FORKING. Trying next Contact.\n"); t_on_failure("SERIAL_FORKING"); t_relay(); }
I want to use RTPProxy in this scenario and I am using the function rtpproxy_manage() to let kamailio handle it automatically.
RTPProxy ↑ | |
Customer --> Kamailio --> Provider1 | | ↓ Provider N
After the 302 response is processed I would like to have the signaling flow "Customer -> Kamailio --> ProviderN" and the RTP flow "Customer --> RTPProxy --> ProviderN"
I have tried inserting the function in several places but can't make it work and what I mean is that sometimes the rtpproxy creates the 1st session and then deletes it as soon as I call it the 2nd time with a message similar to this one (log of rtpproxy) : "INFO:416f20b74a58fb75168175e61b2edece@192.168.1.61:5060:rtpp_cmd_delete_ematch: forcefully deleting session 1 on ports 63502/0". Sometimes the kamailio log shows this message: "ERROR: rtpproxy [rtpproxy.c:2536]: force_rtp_proxy(): incorrect port 0 in reply from rtp proxy"
I think I must call rtpproxy_manage() before I send the INVITE to each of the Providers in the Contact list so they receive a SDP offer with an IP:Port combination provided by the RTPProxy (instead of the ones coming from the Customer). That would be in my route["INCOMING'] Then once Provider_N replies with a 183 with SDP or a 200 OK I would call it again to get a new session to be passed on the reply to my customer. But is the part I am struggling with. Should I add a new reply route inside the failure_route["INCOMING'] only if I am dealing with 302 and do it there ? I am out of ideas guys and any idea is welcome
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Thank you Daniel, I think I need to call it at least 2 times to get the IP:Port combination to be used on the call, then a 3rd time to release the resources (I call it in the loose_route() route section for the ACK and BYE etc):
1- when the request to the Providers obtained in the 302 Response is forwarded, on the branch route as you say seems like a good place for that. But doing it there causes the SDP to have the original IP:Port in the SDP offer and not a new set from the rtpproxy. However if I call rtpproxy_manage() inside the route["INCOMING"] , which is before the 302 response is received then once the Contacts are processed then the INVITE created in the branch route towards them has the new set of IP:Port. Could it be that on the branch route the SDP parameters are not changed ?
2- once the Provider replies with 183 or 200 OK, we need to replace their IP:Port with new ones from the RTPProxy so once we pass the reply to the Customer it sees ours
The 2nd part was the one I was struggling with. I did this as my 1st approach and it works, but I am not sure if it is totally right. I added a "new" t_onreply inside the failure_route called t_on_reply("SERIAL_FORKING_REPLY"), and inside that I called the rtpproxy_manage() and it works. But Is it OK to "create" a new t_onreply route inside a failure_route?
failure_route[INCOMING] { xlog("L_INFO","mylog: INCOMING Failure Route.\n");
#BEGIN 302s handling 1/31/2018 if (t_check_status("302")) { get_redirects("*"); t_on_branch("REDIRECT_BRANCH"); t_load_contacts(); t_next_contacts(); t_on_reply("SERIAL_FORKING_REPLY"); t_on_failure("SERIAL_FORKING"); t_relay(); exit; }
onreply_route["SERIAL_FORKING_REPLY"] { xlog("L_INFO","mylog: In Reply Route SERIAL_FORKING. Reply [$rs]\n"); rtpproxy_manage();
}
I also tried something else, arm the BRANCH route instead with the new t_on_reply("SERIAL_FORKING_REPLY"), and the behavior is the same (I mean it works as well). It looks less awkward to me though. So this is how my REDIRECT_BRANCH looks now.
branch_route[REDIRECT_BRANCH] { xlog("L_INFO","mylog: REDIRECT_BRANCH Route Section. IP is [$Ri].\n"); t_on_reply("SERIAL_FORKING_REPLY"); }
And this is how the failure_route[INCOMING] looks like:
failure_route[INCOMING] { xlog("L_INFO","mylog: INCOMING Failure Route.\n");
#BEGIN 302s handling 1/31/2018 if (t_check_status("302")) { get_redirects("*"); t_on_branch("REDIRECT_BRANCH"); t_load_contacts(); t_next_contacts(); t_on_failure("SERIAL_FORKING"); t_relay(); exit; }
That is my final config, it works as expected.
-----Original Message----- From: Fabian Borot Sent: Monday, February 12, 2018 1:55 PM To: sr-users@lists.kamailio.org Subject: Use RTPProxy in 302 scenario
I have this scenario
Customer --> Kamailio --> Provider1
The route where l route the call to Provider1 is called route["INCOMING"] and I "arm" the replies and failures to : t_on_reply("INCOMING") and t_on_failure("INCOMING"). Provider1 always replies with a 302 Redirect and in the failure_route["INCOMING'] I have this code:
if (t_check_status("302")) { get_redirects("*"); t_on_branch("REDIRECT_BRANCH"); t_load_contacts(); t_next_contacts(); t_on_failure("SERIAL_FORKING"); t_relay(); exit; }
In the t_on_failure("SERIAL_FORKING") block I do t_relay() as long as there are more contacts to be processed. Lets say I need to try Provider_2 and Provider_3
failure_route["SERIAL_FORKING"] { xlog("L_INFO","mylog: In Failure Route SERIAL_FORKING. Reply [$rs]\n"); if (!t_next_contacts()) { exit; } xlog("L_INFO","mylog: In Failure Route SERIAL_FORKING. Trying next Contact.\n"); t_on_failure("SERIAL_FORKING"); t_relay(); }
I want to use RTPProxy in this scenario and I am using the function rtpproxy_manage() to let kamailio handle it automatically.
RTPProxy ↑ | | Customer --> Kamailio --> Provider1 | | ↓ Provider N
After the 302 response is processed I would like to have the signaling flow "Customer -> Kamailio --> ProviderN" and the RTP flow "Customer --> RTPProxy --> ProviderN"
I have tried inserting the function in several places but can't make it work and what I mean is that sometimes the rtpproxy creates the 1st session and then deletes it as soon as I call it the 2nd time with a message similar to this one (log of rtpproxy) : "INFO:416f20b74a58fb75168175e61b2edece@192.168.1.61:5060:rtpp_cmd_delete_ematch: forcefully deleting session 1 on ports 63502/0". Sometimes the kamailio log shows this message: "ERROR: rtpproxy [rtpproxy.c:2536]: force_rtp_proxy(): incorrect port 0 in reply from rtp proxy"
I think I must call rtpproxy_manage() before I send the INVITE to each of the Providers in the Contact list so they receive a SDP offer with an IP:Port combination provided by the RTPProxy (instead of the ones coming from the Customer). That would be in my route["INCOMING'] Then once Provider_N replies with a 183 with SDP or a 200 OK I would call it again to get a new session to be passed on the reply to my customer. But is the part I am struggling with. Should I add a new reply route inside the failure_route["INCOMING'] only if I am dealing with 302 and do it there ? I am out of ideas guys and any idea is welcome