Summary:ASTERISK-02812: bad dependency on order of contexts in sip.conf
Reporter:randyqx (randyqx)Labels:
Date Opened:2004-11-14 09:17:36.000-0600Date Closed:2011-06-07 14:05:27
Versions:Frequency of
Description:> if i have two sip contexts for my spa3k, on inbound and
> one outbound, e.g.
>     [spa3k-in]
>     type=friend
>     host=dynamic
>     port=5061
>     auth=md5
>     secret=pfui
>     qualify=1000
>     canreinvite=yes
>     context=ext-in42
>     [spa3k-out]
>     type=peer
>     auth=md5
>     secret=pfui
>     username=outpass
>     fromuser=outpass
>     host=spa3k.bogus.com
>     port=5061
>     nat=no
>     canreinvite=yes
>     context=ext-in42
> and the spa3k's PSTN / Subscriber Information / User ID: = spack-in,
> the incoming connection from spa3k to * is being routed to the
> spa3k-out context, not the spa3-in context.  see appended.
> i suspect this is a bug in * 1.0.1.

i found the problem, or at least a work-around.

if i reverse the order of the above two sip contexts, the incoming call is properly routed to the spa3k-in sip context as opposed to the wrong one, spa3k-out.

my guess is that * is traversing a list and taking the first context which has the ip address and port it wants without checking the context name against the name which was received over the wire.  so it depends on what order the contexts are inserted in the list.


this took many many hours to find.  and it really diables the utility of the system until it is found.

as usual, absolutely no useful help from the asterisk-users mailing list.  a bsd list member stuck with me and gave some clues.
Comments:By: Mark Spencer (markster) 2004-11-14 09:47:53.000-0600

A friend is equivalent to both a user and peer declaration, ergo you have two peer declarations for the same peer, this will not work.  Please do not place technical support issues in the bug tracker but seek assistance in #asterisk or other places.  Thanks!

By: Olle Johansson (oej) 2004-11-14 09:52:14.000-0600

This is not two "contexts" this is two "device declarations". "context" is used for sections of the dial plan, extensions.conf or voicemail users in voicemail.conf.

Remember that a "friend" is entered in two lists, both as a "user" and then as a "peer". So you have one user and *two* peers to match against here.

For an incoming call, we first match on username to the user list, then on IP to the peer list. You propably want only one "user" and one "peer" to not confuse yourself. Remove the "friend", that one always causes confusion.

Additionally, the "auth=" header is obsolete. Please try with one "peer" and one "user" and confirm if it works for you.