Help on handle 302 moved temporarily response

Hi all, I am trying to best handle in a best way following scenario.
Using asterisk 22 and PJSIP tech.

Given following dialplan it’s working great, but happend that some called endpoint are forwarded and I receive following error:

-- Now forwarding PJSIP/trunk-audiocodes-0000002e to 'Local/+44xxxxxxxx@from-trunk' (thanks to PJSIP/trunk-audiocodes-00000035)
-- Not accepting call completion offers from call-forward recipient Local/+44xxxxxxxx@from-trunk-00000000;1

[Jul 29 11:46:55] NOTICE[562054][C-00000006]: core_local.c:753 local_call: No such extension/context +44xxxxxxxx@from-trunk while calling Local channel
[Jul 29 11:46:55] NOTICE[562054][C-00000006]: app_dial.c:1122 do_forward: Forwarding failed to dial ‘+44xxxxxxxx@from-trunk’

I understand that asterisk cannot handle it because cannot find “new destination” in any context.
Should be a good Idea modify [from-trunk] context adding at the end following code:

exten => _+X.,1,NoOp(Handle all other incoming calls)
same => n,Dial(PJSIP/${EXTEN}@${TRUNK_1},${TIMEOUT},rtT)
same => n,Hangup()

Or are there other way more effective?

below is the current code

[from-trunk]
exten => +4499999991,1,NoOp(Incoming call to TEST from ${CALLERID(num)} to ${EXTEN})
same => n,Set(GROUP_NAME=TEST)
same => n,GoTo(fork-call,${EXTEN},1)

exten => +4499999992,1,NoOp(Incoming call to QAuditor-245 from ${CALLERID(num)} to ${EXTEN})
same => n,Set(GROUP_NAME=QAUDITOR_245)
same => n,GoTo(fork-call,${EXTEN},1)

exten => +4499999993,1,NoOp(Incoming call to QAuditor-246-CQ from ${CALLERID(num)} to ${EXTEN})
same => n,Set(GROUP_NAME=QAUDITOR_246)
same => n,GoTo(fork-call,${EXTEN},1)

exten => +4499999994,1,NoOp(Incoming call to Emergency from ${CALLERID(num)} to ${EXTEN})
same => n,Set(GROUP_NAME=EMERGENCY)
same => n,GoTo(fork-call,${EXTEN},1)

exten => +4499999995,1,NoOp(Incoming call to Emergency from ${CALLERID(num)} to ${EXTEN})
same => n,Set(GROUP_NAME=ADE_EMERGENCY)
same => n,GoTo(fork-call,${EXTEN},1)

[fork-call]
exten => +X.,1,NoOp(Forking call to group ${GROUP_NAME} for ${EXTEN})
same => n,Set(DIAL_STRING=)
same => n,Set(COUNTER=1)
same => n,While(${EXISTS(${ENDPOINTS
${GROUP_NAME}[${COUNTER}]})})
same => n,Set(DIAL_STRING=${DIAL_STRING}PJSIP/${ENDPOINTS_${GROUP_NAME}[${COUNTER}]}@${TRUNK_1}&)
same => n,Set(COUNTER=$[${COUNTER} + 1])
same => n,EndWhile()
same => n,ExecIf(${LEN(${DIAL_STRING})}?Dial(${DIAL_STRING:0:-1},${TIMEOUT},rtT))
same => n,Verbose(0, Dial status: ${DIALSTATUS}, Hangup cause: ${HANGUPCAUSE})
same => n,GotoIf($[“${DIALSTATUS}” = “BUSY”]?busy)
same => n,GotoIf($[“${DIALSTATUS}” = “NOANSWER”]?noanswer)
same => n,GotoIf($[“${DIALSTATUS}” = “CONGESTION”]?congestion)
same => n,GotoIf($[“${DIALSTATUS}” = “CHANUNAVAIL”]?chanunavail)
same => n,Hangup()
same => n(busy),Verbose(0, **** Call was busy ****)
same => n,Hangup(17)
same => n(noanswer),Verbose(0, **** Call not answered ****)
same => n,Hangup(16)
same => n(congestion),Verbose(0, **** Call failed due to congestion ****)
same => n,Hangup(21)
same => n(chanunavail),Verbose(0, **** Channel unavailable ****)
same => n,Hangup(21)

I would first check whether one of the other redirect methods is more appropriate to your use case.

Hi, thank you for hint.
I solved setting

redirect_method=uri_core

to trunk endpoint.

Btw, is it normal that If I do a

pjsip show endpoint <name_endpoint>

redirect_method parameter is not displayed?

See below

asterisk22*CLI> pjsip show endpoint trunk-audiocodes

Endpoint: <Endpoint/CID…> <State…> <Channels.>
I/OAuth: <AuthId/UserName…>
Aor: <Aor…>
Contact: <Aor/ContactUri…> <Hash…> <RTT(ms)..>
Transport: <TransportId…> <BindAddress…>
Identify: <Identify/Endpoint…>
Match: <criteria…>
Channel: <ChannelId…> <State…> <Time…>
Exten: <DialedExten…> CLCID: <ConnectedLineCID…>

Endpoint: trunk-audiocodes Not in use 0 of inf
Aor: trunk-audiocodes 0
Contact: trunk-audiocodes/sip:192.168.1.233:5062 27f5355790 NonQual nan
Transport: transport-udp-nat udp 0 0 0.0.0.0:5060
Identify: trunk-audiocodes/trunk-audiocodes
Match: 192.168.1.233:5062/32

ParameterName : ParameterValue

100rel : yes
accept_multiple_sdp_answers : false
accountcode :
acl :
aggregate_mwi : true
allow : (alaw)
allow_overlap : true
allow_subscribe : true
allow_transfer : true
allow_unauthenticated_options : false
aors : trunk-audiocodes
asymmetric_rtp_codec : false
auth :
bind_rtp_to_media_address : false
bundle : false
call_group :
callerid :
callerid_privacy : allowed_not_screened
callerid_tag :
codec_prefs_incoming_answer : prefer:pending, operation:intersect, keep:all, transcode:allow
codec_prefs_incoming_offer : prefer:pending, operation:intersect, keep:all, transcode:allow
codec_prefs_outgoing_answer : prefer:pending, operation:intersect, keep:all, transcode:allow
codec_prefs_outgoing_offer : prefer:pending, operation:union, keep:all, transcode:allow
connected_line_method : invite
contact_acl :
context : from-trunk
cos_audio : 0
cos_video : 0
device_state_busy_at : 0
direct_media : false
direct_media_glare_mitigation : none
direct_media_method : invite
disable_direct_media_on_nat : false
dtls_auto_generate_cert : No
dtls_ca_file :
dtls_ca_path :
dtls_cert_file :
dtls_cipher :
dtls_fingerprint : SHA-256
dtls_private_key :
dtls_rekey : 0
dtls_setup : active
dtls_verify : No
dtmf_mode : rfc4733
fax_detect : false
fax_detect_timeout : 0
follow_early_media_fork : true
force_avp : false
force_rport : true
from_domain :
from_user :
g726_non_standard : false
geoloc_incoming_call_profile :
geoloc_outgoing_call_profile :
ice_support : false
identify_by : username,ip
ignore_183_without_sdp : false
inband_progress : false
incoming_call_offer_pref : local
incoming_mwi_mailbox :
language :
mailboxes :
max_audio_streams : 1
max_video_streams : 1
media_address :
media_encryption : no
media_encryption_optimistic : false
media_use_received_transport : false
message_context :
moh_passthrough : false
moh_suggest : default
mwi_from_user :
mwi_subscribe_replaces_unsolicited : no
named_call_group :
named_pickup_group :
notify_early_inuse_ringing : false
one_touch_recording : false
outbound_auth :
outbound_proxy :
outgoing_call_offer_pref : remote_merge
overlap_context :
pickup_group :
preferred_codec_only : false
record_off_feature : automixmon
record_on_feature : automixmon
refer_blind_progress : true
rewrite_contact : false
rpid_immediate : false
rtcp_mux : false
rtp_engine : asterisk
rtp_ipv6 : false
rtp_keepalive : 0
rtp_symmetric : false
rtp_timeout : 0
rtp_timeout_hold : 0
sdp_owner : -
sdp_session : Asterisk
security_negotiation : no
send_aoc : false
send_connected_line : yes
send_diversion : true
send_history_info : false
send_pai : false
send_rpid : false
set_var :
srtp_tag_32 : false
stir_shaken : no
stir_shaken_profile :
sub_min_expiry : 0
subscribe_context :
suppress_moh_on_sendonly : false
suppress_q850_reason_headers : false
t38_bind_udptl_to_media_address : false
t38_udptl : false
t38_udptl_ec : none
t38_udptl_ipv6 : false
t38_udptl_maxdatagram : 0
t38_udptl_nat : false
tenantid :
timers : yes
timers_min_se : 90
timers_sess_expires : 1800
tone_zone :
tos_audio : 0
tos_video : 0
transport : transport-udp-nat
trust_connected_line : yes
trust_id_inbound : false
trust_id_outbound : false
use_avpf : false
use_ptime : false
user_eq_phone : false
voicemail_extension :
webrtc : no

HI, I suppose is a version bug.
Doing the same, on asterisk 22.4 it shows parameter; on asterisk 22.2 it doesn’t.
Just for you information :slight_smile:

Regards