Early media not work with asterisk

1,203 views
Skip to first unread message

Ivan Vynogradov

unread,
Feb 18, 2021, 5:30:58 AM2/18/21
to SIP.js
Hello, I'm trying to make sipjs play ringing from Asterisk server before called number answer
from js side:
this.inviterOptions = {
earlyMedia: true
}

user.call(target, this.inviterOptions, {}

but ring working only if server answer(200)
and not work if 183 received

from asterisk side I've tried to use
;exten => _X.,n,Progress()
;exten => _X.,n,PlayTones(ring)
;exten => _X.,n,Wait(5)
and
;exten => _X.,n,Progress()
;exten => _X.,n,Wait(1)
exten => _X.,n,Dial(PJSIP/${EXTEN}@pbx16,,r)

but work only:
exten => _X.,n,Answer()
exten => _X.,n,Dial(PJSIP/${EXTEN}@pbx16,,r)

is any other way to to say sipjs playtone before channel was answered

Ivan Vynogradov

unread,
Feb 18, 2021, 7:21:42 AM2/18/21
to SIP.js
And I've tried to add
this.sipExtension100rel = SIPExtension.Required;

this.simpleUserOptions = {
.....
sipExtension100rel: this.sipExtension100rel,
}

четверг, 18 февраля 2021 г. в 12:30:58 UTC+2, Ivan Vynogradov:

James Criscuolo

unread,
Feb 19, 2021, 11:44:56 AM2/19/21
to SIP.js
Full logs in a gist would be helpful here, it's likely an asterisk side issue.

Ivan Vynogradov

unread,
Feb 23, 2021, 2:18:39 AM2/23/21
to SIP.js

https://gist.github.com/ipvinner/e4f103f7de4eb6cda18127760c76b4fa

пятница, 19 февраля 2021 г. в 18:44:56 UTC+2, James Criscuolo:

Slavik Bialik

unread,
Feb 23, 2021, 4:30:50 AM2/23/21
to SIP.js
It is missing all the logs. It is only a few lines, and most importantly you need to put the full SIP messages as well.

Ivan Vynogradov

unread,
Feb 23, 2021, 6:03:00 AM2/23/21
to SIP.js

I've updated gist log. 
Enabled Sip debug.
https://gist.github.com/ipvinner/e4f103f7de4eb6cda18127760c76b4fa
вторник, 23 февраля 2021 г. в 09:18:39 UTC+2, Ivan Vynogradov:

Slavik Bialik

unread,
Feb 23, 2021, 6:09:53 AM2/23/21
to SIP.js
OK, I can see the problem immediately. 
The issue is that you're not getting back a 183 Session in Progress. Because 183 message should come with SDP and ICE candidates and all the rest that is needed for this to work.
When you are enabling "earlyMedia: true" it will work only if 183 and SDP is provided.
So it looks like the issue is not on SIP.js, but on Asterisk / PSTN side. If your PSTN returns 180 Ringing, it'll be passed through until it reaches the client. I don't know Asterisk, but I do not think that you will be able to "translate" the 180 into 183 on your PBX side, unless if you will configure your dial plan to send back 183 on the inbound leg (from your SIP.js client) and to play some static ringback tone (this is something that I did in my deployment when calling between 2 SIP.js clients - internal calls - but on FreeSWITCH, not Asterisk). But doing so towards PSTN numbers I do not like this solution of having static ringback tone that Asterisk will play, because sometimes you may hear different things from PSTN like voice mails and etc, so I would suggest to contact your ITSP provider and ask them if they can return 183 Session in Progress instead of 180 Ringing.

Ivan Vynogradov

unread,
Feb 23, 2021, 6:21:29 AM2/23/21
to SIP.js
I've enabled 183 now:
debug is here, and attached screen from server side.
https://gist.github.com/ipvinner/992044a5c582d8f9d1c8ae70207f2f80

But still don't hear anything.

вторник, 23 февраля 2021 г. в 13:09:53 UTC+2, litt...@gmail.com:
sipDump183Enabled.png

Nahid Rezaei

unread,
Feb 6, 2023, 3:50:12 AM2/6/23
to SIP.js
Is there anyone can help?
I have this problem too. when I used answer() in my asterisk early media is OK but call is answered always. but when I use progress() early media is not played.
Reply all
Reply to author
Forward
0 new messages