Hi, I want to realise scheme:

Asterisk->Kamailo->provider

I register several provider accounts at Kamailio using UAC module.

When Client Generates call form Asterisk through Kamailio to provider, provider sends back 407 response. This reponse must be handled by Kamailio through failure_route using uac_auth().

I try to catch this response at onreply_route by status and route this response to failure route (t_on_failure("MY_FAILURE_ROUTE"))but Kamailio ignores t_on_failure and forward this packet to asterisk (As I think because asterisk generator of session) 

So My question is: How to handle this response at kamailio and not forward to asterisk? 

This is invite that forwards to provider:

INVITE sip:11234567890@my.provider.com:5060 SIP/2.0
Record-Route: <sip:my.kamailio.com:5068;nat=yes;ftag=as57a2d34c;lr=on>
Via: SIP/2.0/UDP my.kamailio.com:5068;branch=z9hG4bK8544.480e25d0e6a328f5f455233d808cda80.0
Via: SIP/2.0/UDP 10.0.1.6:50600;branch=z9hG4bK778521b0;rport=50600
Max-Forwards: 70
From: "John" <sip:my_provider_acc@my.provider.com:50600>;tag=as57a2d34c
To: <sip:11234567890@my.provider.com:5068>
Contact:<my_provider_acc@my.kamailio.com:5068>
Call-ID: 3d8d6c357d69cdd51633b1c125729f44@10.0.1.6:50600
CSeq: 102 INVITE
User-Agent: Asterisk PBX 12.4.0
Date: Sat, 16 Aug 2014 13:18:52 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 540

v=0
o=root 1941643043 1941643043 IN my.kamailio.com
s=Asterisk PBX 12.4.0
c=IN IP4 my.kamailio.com
t=0 0
a=ice-lite
m=audio 30108 RTP/AVP 0 3 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:3 GSM/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
a=rtcp:30109
a=ice-ufrag:jOv9GFqq
a=ice-pwd:wuXGbJ3ZI7MfwM6kwto78s8reEyU
a=candidate:lzqT8la5i9wkzQzB 1 UDP 2130706431 my.kamailio.com 30108 typ host
a=candidate:lzqT8la5i9wkzQzB 2 UDP 2130706430 my.kamailio.com 30109 typ host