Call routing issue

Hi Champs,

I have setup asterisk server but facing issue on call routing

Outside calls not landling on my softphone through provider (sip provider)


[Dec 5 19:04:49] NOTICE[3756][C-00000001]: chan_sip.c:25894 handle_request_invite: Call from ‘provider’ ( to extension ‘s’ rejected because extension not found in context ‘from-pstn’.

[Dec 5 19:24:13] WARNING[3729]: db.c:288 db_execute_sql: Error executing SQL (COMMIT): database is locked

SIP config


Extension Config

exten => _0X.,1,Goto(phones,100,1)

exten => 100,1,NoOp()
same => n,MixMonitor(${UNIQUEID}.wav,ab)
same => n,Dial(SIP/sandeepk)
same => n,StopMixMonitor()
same => n,Hangup()

sandeepk is my softphone (joiper) in remote country with connectivity over vpn (port 5060 opened)

sip show peers

sandeepk/sandeepk xxxxxx Yes Yes 5060 Unmonitored

Waiting for your response

Thanks in advance.

The answer already here - extension s was not found in context ‘from-pstn’, you have “_0X.” pattern there and “s” does not match this pattern.

s is used on chan_sip if there is no user part in the request URI, ie. the ITSP is not forwarding any of the dialled digits.

In this case ‘s’ is a user part of request URI, because client has registered in such way with ITSP.
ITSP is probably forwarding dialled digits in To:

Hi thanks for the quick response

SIP number is starting with 02 xxxx xxxx so i have included _0X

what should i do to fix this asap


The SIP number does not start with 02. The ITSP is not sending the SIP number.

Either get the ITSP to send the number, or change your dailplan to match the “s” placeholder.

PS. Responders in peer support forums will generally ignore your indications of urgency or they may even have a negative effect on responses…

Hi David,

thanks for quick assistance and apologize for “urgent” keyword

change your dailplan to match the “s” placeholder - could you pls share the correct diaplan to get it working

Many thanks

Change the _02… to s

Clean way:
get rid of ‘register =’

Add to your trunk config

change context=from-pstn to context=custom-get-did-from-sip

Add one more context

exten => s,1,Goto(from-pstn,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)

Restore your initial template with _02
I’m assuming you see the number starting with 02 in the To: header of the incoming INVITE.

That parse for To headers won’t work with phrase < address spec > format headers. It also won’t work if there is a space after the :.

If the ITSP is providing a proper direct in dialling service, the request URI should contain dialled digits. If not, To should be irrelevant and all numbers traffic from that peer should be treated alike.

just to add the clarity, here’s the call flow

02 xxxx xxxx (SIP primary trunk) >>> >>call forwarding to internal phone >>>>>>>>>>>>>>>>>.>>>>softphone/hardphone

Potentially and probably only when registration is not in use.
If registration is in place it will contain whatever customer put the Contact header during registration, i.e. what was in callbackextension= or in register=

get rid of ‘register =’ I have commented this line

callbackextension=s added this under sip [provider] settings

change context=from-pstn to context=custom-get-did-from-sip Done

Add one more context

exten => s,1,Goto(from-pstn,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1) Done

Restore your initial template with _02 - please elaborate


If you made a change as suggested earlier

(which is really a quick fix, indeed) - please change it back to your initial “exten => _0X.,1,…” and test.

Hi Now there’s little improvement but getting this error

– Executing [100@phones:1] NoOp(“SIP/provider-00000000”, “”) in new stack
– Executing [100@phones:2] MixMonitor(“SIP/provider-00000000”, “1480999380.0.wav,ab”) in new stack
– Executing [100@phones:3] Dial(“SIP/provider-00000000”, “SIP/sandeepk”) in new stack
== Begin MixMonitor Recording SIP/provider-00000000
[Dec 6 15:43:00] WARNING[23627][C-00000000]: app_dial.c:2455 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)
** == Everyone is busy/congested at this time (1:0/0/1)**
– Executing [100@phones:4] StopMixMonitor(“SIP/provider-00000000”, “”) in new stack
== MixMonitor close filestream (mixed)
– Executing [100@phones:5] Hangup(“SIP/provider-00000000”, “”) in new stack
== Spawn extension (phones, 100, 5) exited non-zero on ‘SIP/provider-00000000’
== End MixMonitor Recording SIP/provider-00000000

please help

latest error

[Dec 6 16:05:57] WARNING[23586]: chan_sip.c:4037 retrans_pkt: Retransmission timeout reached on transmission xxxx@xxxx for seqno 102 (Critical Request) – See
Packet timed out after 32000ms with no response

I hope we are very close to fix it, please lets do it, thanks

[quote=“sandeepk85, post:16, topic:68982”]
[Dec 6 16:05:57] WARNING[23586]: chan_sip.c:4037 retrans_pkt: Retransmission timeout reached on transmission xxxx@xxxx for seqno 102 (Critical Request) – See
Packet timed out after 32000ms with no response

I hope we are very close to fix it, please lets do it, thanks

The Retrans packet one is normally a firewall or NAT issues, i.e. either the request is never reaching the ITSP or the reponse is not getting back. In the latter case will be because it is being blocked, or because it is being sent to the wrong address (e.g. to your LAN private address,

Note, if your current configuration, above, is complete, it is not suitable for use from inside NAT (the nat options there are mainly for when the phones are inside, but Asterisk is outside). You need to tell Asterisk how to find its public address.

It seems the initial issue is solved and now you’re facing absolutely different problem.
You need to enable sip debug for ‘sandeepk’ and check what’s going on during the call attempt towards that peer.

Make sure your softphone has all the NAT traversal techniques switched off.
Add your VPN subnet as ‘localnet=’ in Asterisk.
I’m assuming that your phone has a direct VPN connection to your server without external VPN provider.

Further investigation will require clear readable sip trace, otherwise we will be only able to guess and provide general recommendations which might have no direct relation to the particular issue.


Now i needs to forward incoming sip call to another sip number (other country)

please guide how i can achieve this. Don’t i needs to register destination sip number first in SIP file /asterisk so that destination phone can receive the calls?

Is it possible to terminate coming sip call to any other mobile/landline even when its not registered in our asterisk server

please shed some light on this

what other ports needs open, other things i needs to take care of

I’m newbie to asterisk hence don’t have full clarity on the call flow

waiting for the response

Thanks in advance