Asterisk chosing peer instead of user on incoming call


#1

Hello
I have noticed this on versions Asterisk 1.8.5.0 and Asterisk 1.8.3.3
In sip.conf, I have 2 entries with the same IP:
1- a peer, no context and 1 codec
2- a user, a context and 3 codecs

So, lets say that a call comes from that IP, asterisk should choose the settings of the entry set as a user, then go to the context and find an extension that matches the dialed number and go on from there.
What is happening is that is chooses the entry configured as a peer, since it has no context then it goes to the “default” context, since there is no extension that matches the call fails.

I have tried setting the “peer” with a context but it has the same effect, it chooses the peer instead of the “user”, I have also put the “user” first in the sip.conf. I have also tried with “friend” instead of “user” and the same thing happens.

The main reason to have IP twice is because we need a set of codecs when we send calls to that IP [peer] and another set of codecs when we receive from that IP [user or friend]

This used to work fine in version 1.6, could it be a bug or do we need to use a special configuration?
txs in advance
fborot


#2

The IP address is irrelevant for user entries. The matching is based on the part of the Contact: header ( before ‘@’ )

You should remove the user part and read about SIP_CODEC_OUTBOUND variable.


#3

txs thor, so basically I should be able to use 1 entry on sip.conf with all allowed codecs [lest say g729, ulaw,alaw, gsm] and then on the extensions.conf, on the dialplan I can change the codec for any leg [inbound and outbound].
Can I even set the ptime?

will something like this work?
case-1 calls from any peer to My_Provider using specifically g729:60 on the B-leg

exten => 1234.,1,NoOp(Incoming call to My_Provider)
exten => 1234.,n,SET(${SIP_CODEC_OUTBOUND}=G729:60)
exten => 1234.,n,Dial(SIP/My_Provider/${EXTEN})
exten => 1234.,n,HangUp()

case-2 calls from My_Provider using specifically ulaw on the A-leg

exten => 5678.,1,NoOp(Incoming call from My_Provider)
exten => 5678.,n,SET(${SIP_CODEC_INBOUND}=ulaw)
exten => 5678.,n,Dial(SIP/My_Other_Provider/${EXTEN})
exten => 5678.,n,HangUp()

txs again
fborot


#4

No ${} on the left hand side of Set(), just the variable name.


#5

txs a lot, I will try it, even the ptime can be set?


#6

it looks like the variable is read-only or it does not work, I see the INVITE with all codecs defined for the peer.
I apply the set before the dial:

exten => 1234.,1,NoOp(Incoming call to My_Provider)
exten => 1234.,n,SET(SIP_CODEC_OUTBOUND=g729)
exten => 1234.,n,Dial(SIP/My_Provider/${EXTEN})
exten => 1234.,n,HangUp()

I see this on the console but the actual INVITE shows all codecs,

– Executing [1234100@from_incoming:2]Set("SIP/My_Provider ", “SIP_CODEC_OUTBOUND=g729”) in new stack


#7

any ideas why setting the variable does not work?
what changed that now asterisk gets confused when choosing the right peer?


#8

I found out that the variable needs to be set with a “_” in front
_SIP_CODEC_OUTBOUND=g729


#9

the usage of this variable although useful for some scenarios is a limited workaround for our purposes.

IMHO asterisk definitely has issues with this configuration. I installed the latest version [Asterisk 1.8.5.0 built by root @ asterisk1-8.mydomain.com on a x86_64 running Linux on 2011-08-26 21:31:22 UTC] on Friday and it worked fine for while but this morning started to show the same issue. I changed the names a little bit of the providers to kind of trick asterisk [the names where almost the same, Provider-1 and Provider-2] and it is working again but who knows when it will fail again.
I found that there was a similar issue [issues.asterisk.org/view.php?id=14256] and tried the latest version but my success was short lived.