Inbound context not working

Hello everyone,

I have issue with my context in asterisk. I have many numbers registered from a provider, and each registered number has specific context. But when I call a number, the context fired is the first context in sip.conf. Here is an exemple:

register => 0033188320001:password@context1/0033188320001
register => 0033188320002:password@context2/0033188320002
register => 0033188320003:password@context3/0033188320003

[context1]
type=friend
host=providerhost
context=from-context1
language=fr
insecure=invite
username=0033188320001
defaultuser=0033188320001
fromuser=0033188320001
authuser=0033188320001
secret=password
fromdomain=providerhost
nat=no
canreinvite=no
dtmfmode=auto
video=no
restrictcid=no
disallow=all
allow=g722
allow=ulaw
allow=alaw

[context2]
type=friend
host=providerhost
context=from-context2
language=fr
insecure=invite
username=0033188320002
defaultuser=0033188320002
fromuser=0033188320002
authuser=0033188320002
secret=password
fromdomain=providerhost
nat=no
canreinvite=no
dtmfmode=auto
video=no
restrictcid=no
disallow=all
allow=g722
allow=ulaw
allow=alaw

[context3]
type=friend
host=providerhost
context=from-context3
language=fr
insecure=invite
username=0033188320003
defaultuser=0033188320003
fromuser=0033188320003
authuser=0033188320003
secret=password
fromdomain=providerhost
nat=no
canreinvite=no
dtmfmode=auto
video=no
restrictcid=no
disallow=all
allow=g722
allow=ulaw
allow=alaw

No matter which the number called, it is the “from-context1” that is triggered in my extension.conf because it is in first on the sip.conf. If I change and put [context2] in first, the context triggered is “from-context2”.

Any idea ?

Thanks for your help.

Expected behaviour for a type=peer match. It is likely that the from user is the caller ID, so there will be no type=user match, and type=friend will behave like type=peer. Assuming these accounts are designed for PABX use, you need to ues the callback extension number to route the incoming calls.

Show us the signaling, Do the invites to your PBX from your provider have a username specified?