[OpenSER-Users] Handle 302 Moved Temporarily

Bogdan-Andrei Iancu bogdan at voice-system.ro
Sat Jul 5 17:53:42 CEST 2008


Hi Dmitry,

you should not use the  rewritehostport () after get_redirects("*") - 
get_redirects() internally appends the extracted branches, so you cannot 
change anything about them from the script.

Also, try to set soem debug for the get_redirects("*") to see what 
happens there (you may use dynamic debug level via setdebug():

http://www.openser.org/dokuwiki/doku.php/core-cookbook:1.3.x#setdebug_level

regards,
Bogdan


Dmitry Lyubimkov wrote:
> We need process 302 redirection Message in our OpenSER (ver 1.3) script.
> we use failure_route
>
> failure_route[1]                 
> {
>
>     append_hf("Transfer-code: $T_reply_code\r\n");
>     if t_check_status("(302)|(301)"){
>         append_hf("Original-URI: $ru\r\n");
>         get_redirects("*");
>        rewritehostport("172.16.2.6");
> #       append_branch();
>         route(1);
>    } else 
>     if t_check_status("(408)|(486)"){
>         rewritehostport("172.16.2.6");
>         append_branch();
>         route(1);
>     };
> }
>
> All fails with 4xx code (Timeout, Busy) work right. OpenSER send them to
> asterisk (172.16.2.6). But we cannot do the same with 301 and 302 code,
> because there is a header Contact in their replies. And we need to change
> our URI according this field.
> Using Tcpdump I get some diagnostic:
> Invite to UA:
>
> 18:48:31.898163 IP 78.36.60.131.sip > 172.16.76.4.53568: SIP, length: 1258
> E..... at .@...N$<...L.... at ....INVITE
> sip:loft at 172.16.76.4:53568;rinstance=87e2d8d91648c3bf SIP/2.0
> Record-Route: <sip:78.36.60.131;lr;ftag=2D551EE4-2538;nat=yes>
> Via: SIP/2.0/UDP voapp.ru:5060;branch=z9hG4bK8b81.6f656603.0
> Via: SIP/2.0/UDP  78.36.60.129:5060;rport=52061;x-route-tag="tgrp:m200"
> From: <sip:78142722856 at 78.36.60.129>;tag=2D551EE4-2538
> To: <sip:78142599298 at 78.36.60.131>
> Date: Fri, 04 Jul 2008 14:39:48 GMT
> Call-ID: E338E8F0-490D11DD-834CC831-1B0A3D9F at 78.36.60.129
> Supported: timer,100rel
> Min-SE:  1800
> Cisco-Guid: 3812117704-1225593309-2202650673-453655967
> User-Agent: Cisco-SIPGateway/IOS-12.x
> Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, COMET, REFER, SUBSCRIBE,
> NOTIFY, INFO
> CSeq: 101 INVITE
> Max-Forwards: 5
> Timestamp: 1215182388
> Contact: <sip:78142722856 at 78.36.60.129:5060>
> Expires: 180
> Allow-Events: telephone-event
> Content-Type: application/sdp
> Content-Length: 375
>
> Reply witn 302 code:
> 18:48:32.019255 IP 172.16.76.4.53568 > 78.36.60.131.sip: SIP, length: 474
> E...\...}.]+..L.N$<.. at ....
> .SIP/2.0 302 Moved Temporarily
> Via: SIP/2.0/UDP
> voapp.ru:5060;branch=z9hG4bK8b81.6f656603.0;received=78.36.60.131
> Via: SIP/2.0/UDP  78.36.60.129:5060;rport=52061;x-route-tag="tgrp:m200"
> Contact: <sip:78142705353 at voapp.ru>
> To: <sip:78142599298 at 78.36.60.131>;tag=e3040a33
> From: <sip:78142722856 at 78.36.60.129>;tag=2D551EE4-2538
> Call-ID: E338E8F0-490D11DD-834CC831-1B0A3D9F at 78.36.60.129
> CSeq: 101 INVITE
> User-Agent: X-Lite release 1011s stamp 41150
> Content-Length: 0
>
> Our acknoledgement:
> 18:48:32.019395 IP 78.36.60.131.sip > 172.16.76.4.53568: SIP, length: 395
> E..... at .@..yN$<...L.... at ...`ACK
> sip:loft at 172.16.76.4:53568;rinstance=87e2d8d91648c3bf SIP/2.0
> Via: SIP/2.0/UDP voapp.ru:5060;branch=z9hG4bK8b81.6f656603.0
> From: <sip:78142722856 at 78.36.60.129>;tag=2D551EE4-2538
> Call-ID: E338E8F0-490D11DD-834CC831-1B0A3D9F at 78.36.60.129
> To: <sip:78142599298 at 78.36.60.131>;tag=e3040a33
> CSeq: 101 ACK
> Max-Forwards: 70
> User-Agent: OpenSER (1.3.1-notls (i386/linux))
> Content-Length: 0
>
> And new Invite:
> 18:48:32.019762 IP 78.36.60.131.sip > 172.16.76.4.53568: SIP, length: 1327
> E..K.. at .@...N$<...L.... at .7..INVITE sip:78142705353 at 172.16.76.4:53568 SIP/2.0
> Record-Route: <sip:78.36.60.131;lr;ftag=2D551EE4-2538;nat=yes>
> Via: SIP/2.0/UDP voapp.ru:5060;branch=z9hG4bK8b81.6f656603.1
> Via: SIP/2.0/UDP  78.36.60.129:5060;rport=52061;x-route-tag="tgrp:m200"
> From: <sip:78142722856 at 78.36.60.129>;tag=2D551EE4-2538
> To: <sip:78142599298 at 78.36.60.131>
> Date: Fri, 04 Jul 2008 14:39:48 GMT
> Call-ID: E338E8F0-490D11DD-834CC831-1B0A3D9F at 78.36.60.129
> Supported: timer,100rel
> Min-SE:  1800
> Cisco-Guid: 3812117704-1225593309-2202650673-453655967
> User-Agent: Cisco-SIPGateway/IOS-12.x
> Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, COMET, REFER, SUBSCRIBE,
> NOTIFY, INFO
> CSeq: 101 INVITE
> Max-Forwards: 5
> Timestamp: 1215182388
> Contact: <sip:78142722856 at 78.36.60.129:5060>
> Expires: 180
> Allow-Events: telephone-event
> Content-Type: application/sdp
> Content-Length: 375
> Transfer-code: 302
> Original-URI: sip:loft at 172.16.76.4:53568;rinstance=87e2d8d91648c3bf
>
> But why sip:78142705353 at 172.16.76.4:53568?
> Why not 172.16.2.6 (rewritehostport("172.16.2.6");) or
> sip:78142705353 at voapp.ru (Contact: <sip:78142705353 at voapp.ru>)?
>
> Where is error? I need to sent all 3xx redirects to dedicated server but I
> also need to get Contact header from UA reply and put it in outgoung
> message. What commands must I use? Can anybody help me and get fragment of
> openser script?
>
> Thx
> Dmitry
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.openser.org
> http://lists.openser.org/cgi-bin/mailman/listinfo/users
>
>   





More information about the Users mailing list