Passing ‘302 Moved Temporarily’ Back To The SIP Provider

Home » Asterisk Users » Passing ‘302 Moved Temporarily’ Back To The SIP Provider
Asterisk Users 4 Comments

Hello,

I ‘m looking for a way to pass the ‘302 moved temporarily’ received from the SIP device back to the SIP provider. Here is the setup:
Some SIP phones are connected to an Asterisk System version 1.8. External connection to the public network is also done via SIP to a VoIP provider.

Phone A has a CFW all calls to a phone number in public network (Mobile Phone)

incoming call to Phone A, Phone A sends back a 302 response. This results in:
— Got SIP response 302 “Moved Temporarily” back from 192.168.2.188:5072
— Now forwarding SIP/public-000000e7 to ‘Local/00662943825@internal_extensions’ (thanks to SIP/25-000000e8)
[May 7 12:22:15] NOTICE[31241]: app_dial.c:859 do_forward: Not accepting call completion offers from call-forward recipient Local/00662943825@internal_extensions-f967;1

and a Dial via Local channel to the SIP provider is made. However, two channels are consumed and bandwith is wasted.

Second approach:
I tried to catch the redirect in the call forward context which is defined before the Dial statement:
and do the redirect with app_transfer.

e.g. snippet from macro-stdexten:
exten => s,n,Set(_FORWARD_CONTEXT=from_sip_forward)
exten => s,n,Dial(${ARG2},${ARG4},tTfwW)

[from_sip_forward]
include => internal_devices exten => _X.,1,Verbose(1,${CALLERID(num)} tries call forward to ${EXTEN} for device ${CALLERID(rdnis)})
exten => _X.,n,Transfer(${EXT_TRUNK}/${EXTEN})
exten => _X.,n,NoOp(Transfer STATUS: ${TRANSFERSTATUS})

However, this does not work,

Is there a way to send the 302 response to the VoIP provider ?

Thanks.

Hans

4 thoughts on - Passing ‘302 Moved Temporarily’ Back To The SIP Provider

  • promiscredir= yes in sip.conf should help you achieve your requirement.

    –Satish Barot Ahmedabad, India.

  • I haven’t been able to get that to work in a similar situation, except we are the provider. It results in the new invite being from the CLID of the original caller, and fails.

  • Completely misunderstood the OP!
    Revised solution:
    Set promiscredir= no in sip.conf. I assume you land your dids in
    [incoming-trunk] and here is the basic dialplan tested on 11 but should work on 1.8.

    [incoming-trunk]
    ;– Handle Incoming DIDs. Mine start with 89 and are of 4 digits –;
    exten => _89XX,1,Noop(RDNIS=${CALLERID(rdnis)}::ANI=${CALLERID(ani)}::DNID=${CALLERID(dnid)})
    same => n,Set(__ORIGCHANNEL=${CHANNEL})
    same => n,Dial(SIP/${EXTEN},30)

    ;– Dialplan to handle 302 Moved temporarily –;
    exten => _X..,1,Noop(ORIGCHANNEL=${ORIGCHANNEL}::RDNIS=${CALLERID(rdnis)}::ANI=${CALLERID(ani)}::DNID=${CALLERID(dnid)}::CHANNELTYPE=${CHANNEL(channeltype)})
    same => n,ExecIf($[“${CALLERID(rdnis)}”!=””]?ChannelRedirect(${ORIGCHANNEL},back2provider,${EXTEN},1)
    same => n,Hangup()

    [back2provider]
    ;–Send 302 back to provider –;
    exten => _X.,1,Transfer(${EXTEN})
    same => n,NoOp(TRANSFERSTATUS=${TRANSFERSTATUS})
    same => n,Hangup()

    –Satish Barot Ahmedabad, India