Why 2 contextsfor a provider in sip.conf?

Hello.

In many tutorials, i see that in sip.conf there is 2 context for the same sip provider.

One in and one out.

I made tests using the same context for the in and out and it seem to work also.

What is the interest to insert 2 contexts for the same sip provider ?

Thank you

Only the context in the incoming one should be relevant, or did you think that all Asterisk section names were contexts?

It can sometimes help with authentication issues if there are separate sections, and I think some GUIs always do that, as the easy option. However, with appropriate use of type=peer and insecure=invite, most ITSPs only need one.

I am sorry.

I was looking for the good name but i didn’t find it. Please forget the word context.

I wanted to say that there is two sections in the sip.conf for the same provider in many tutorials.

For example i have find :

[code][freephonie-out] ; on déclare le point d’accès SIP pour les appels sortants
type=peer
host=freephonie.net
username=mon_numero_telephone_freephonie
fromuser=mon_numero_telephone_freephonie
secret=mon_mot_de_passe_freephonie
nat=yes

[freephonie-in] ; Et pour les appels entrants
type=peer
context=fromfree
host=freephonie.net
[/code]

And the same for many many sip providers in many many tutorials.

Why two sections ?

Thank you.

The incoming have
type=user

the outgoing have
type=peer

You receive calls from a user and you send calls to peers.

you can combine both sections in one section if you set
type=friend

Examples split it up because a few providers use other configurations for incoming and outgoing calls. Or you can have only outgoing calls to a gsm-gateway or so.

The example with two type=peer’s is broken, because it is relying on the the last entry being matched for incoming calls, but that is not guaranteed behaviour. It’s use of nat=yes is almost certainly wrong (a very common error).

It is very unusual to need type=friend with SIP. In cases where you can use a single entry, type=peer is almost always the correct choice.

A lot of SIP providers seem to give out incorrect configurations. Mostly they work with Asterisk 1.4, but many start breaking for later versions.