I’m connecting a webrtc client to Asterisk 16, but I can’t hear the audio playback (dialed 200, and I should hear the demo-congrats audio file). Connecting with a SIP softphone works fine. The connections are within the same LAN segment.
This is my pjsip.conf:
[transport-wss]
type=transport
protocol=wss
bind=0.0.0.0
; All other transport parameters are ignored for wss transports.
[patient]
type=aor
max_contacts=5
remove_existing=yes
[patient]
type=auth
auth_type=userpass
username=patient
password=patient
[patient]
type=endpoint
aors=patient
auth=patient
dtls_auto_generate_cert=yes
webrtc=yes
; Setting webrtc=yes is a shortcut for setting the following options:
; use_avpf=yes
; media_encryption=dtls
; dtls_verify=fingerprint
; dtls_setup=actpass
; ice_support=yes
; media_use_received_transport=yes
; rtcp_mux=yes
;;;;direct_media=no
;;;;max_audio_streams=10
;;;;max_video_streams=10
context=default
disallow=all
allow=opus,alaw,ulaw,gsm,vp8,h264
rtp_symmetric=yes
force_rport=yes
[doctor]
type=aor
max_contacts=5
remove_existing=yes
[doctor]
type=auth
auth_type=userpass
username=doctor
password=doctor
[doctor]
type=endpoint
aors=doctor
auth=doctor
dtls_auto_generate_cert=yes
webrtc=yes
; Setting webrtc=yes is a shortcut for setting the following options:
; use_avpf=yes
; media_encryption=dtls
; dtls_verify=fingerprint
; dtls_setup=actpass
; ice_support=yes
; media_use_received_transport=yes
; rtcp_mux=yes
;;;;direct_media=no
;;;;max_audio_streams=10
;;;;max_video_streams=10
context=default
disallow=all
allow=opus,alaw,ulaw,gsm,vp8,h264
rtp_symmetric=yes
force_rport=yes
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
[201]
type=endpoint
context=default
disallow=all
allow=alaw,ulaw,gsm
auth=201
aors=201
[201]
type=auth
auth_type=userpass
password=201
username=201
[201]
type=aor
max_contacts=1
The dialplan:
[default]
exten => 200,1,Answer()
same => n,Playback(demo-congrats)
same => n,Hangup()
exten => patient,1,Answer()
same => n,Dial(PJSIP/${EXTEN})
same => n,Hangup()
exten => doctor,1,Answer()
same => n,Dial(PJSIP/${EXTEN})
same => n,Hangup()
<html>
<head>
<script src="./assets/js/jssip.js" ></script>
<script>JsSIP.debug.enable('JsSIP:*');</script>
</head>
<body>
<script>
// Create our JsSIP instance and run it:
var socket = new JsSIP.WebSocketInterface('wss://sip.domain.org:8090/ws');
var configuration = {
sockets : [ socket ],
uri : 'sip:doctor@sip.domain.org',
password : 'doctor',
display_name : 'doctor',
contact_uri : 'sip:doctor@sip.domain.org',
realm : 'asterisk'
};
var ua = new JsSIP.UA(configuration);
ua.start();
ua.register();
// Register callbacks to desired call events
var eventHandlers = {
'progress': function(e) {
console.log('call is in progress');
},
'failed': function(e) {
console.log('call failed with cause: '+ e.data.cause);
},
'ended': function(e) {
console.log('call ended with cause: '+ e.data.cause);
},
'confirmed': function(e) {
console.log('call confirmed');
}
};
var options = {
'eventHandlers' : eventHandlers,
'mediaConstraints' : { 'audio': true, 'video': true }
};
var session = ua.call('sip:200@sip.domain.org', options);
</script>
</body>
</html>
Looks simple, and I’m trying to KIS, but in this simple “hello world” sample, I still can’t hear anything, and I’m in the same LAN segment.
The Asterisk console and pjsip show enpoints does show me however that something’s up:
Endpoint: doctor In use 1 of inf
InAuth: doctor/doctor
Aor: doctor 5
Contact: doctor/sip:doctor@10.215.144.48:52961;tran 1dd81c2968 NonQual nan
Channel: PJSIP/doctor-0000000b/Playback Up 00:00:21
Exten: 200 CLCID: “” <>
Strange though…
Even if I try the JsSIP demo here: http://tryit.jssip.net/ and configure it to connect to my Asterisk server, I get the following on the console:
== WebSocket connection from 'my_client_ip_addr:52531' for protocol 'sip' accepted using version '13'
-- Added contact 'sip:doctor@my_client_ip_addr:52531;transport=ws' to AOR 'doctor' with expiration of 600 seconds
== Setting global variable 'SIPDOMAIN' to 'sip.domain.org'
-- Executing [200@default:1] Answer("PJSIP/doctor-0000000c", "") in new stack
> 0x7f26f0046c40 -- Strict RTP learning after remote address set to: my_client_ip_addr:51268
> 0x7f26f00064f0 -- Strict RTP learning after remote address set to: my_client_ip_addr:51268
> 0x7f26f0046c40 -- Strict RTP learning after remote address set to: my_client_ip_addr:51268
> 0x7f26f00064f0 -- Strict RTP learning after ICE completion
-- Executing [200@default:2] Playback("PJSIP/doctor-0000000c", "demo-congrats") in new stack
-- <PJSIP/doctor-0000000c> Playing 'demo-congrats.gsm' (language 'en')
> 0x7f26f00064f0 -- Strict RTP switching to RTP target address my_client_ip_addr:51268 as source
> 0x7f26f0046c40 -- Strict RTP switching to RTP target address my_client_ip_addr:51268 as source
> 0x7f26f0046c40 -- Strict RTP learning complete - Locking on source address my_client_ip_addr:51268
> 0x7f26f00064f0 -- Strict RTP learning complete - Locking on source address my_client_ip_addr:51268
-- Executing [200@default:3] Hangup("PJSIP/doctor-0000000c", "") in new stack
== Spawn extension (default, 200, 3) exited non-zero on 'PJSIP/doctor-0000000c'
I’m using both Chrome and Firefox (latest versions), no apparent errors, but I can’t hear anything at all (no “demo-congrats”).
I opened tcp 8090 in my case and udp ports 20000 to 40000 according to my rtp.conf.
You are playing back a GSM encoded file, it will need to transcode. Make sure opus is installed, or try calling another instance of the JsSIP demo with say Edge this time. (You can share the mic and speakers, but it does create a feedback loop if its working). Another thing to try is to use ULAW codec in your endpoints - just to test, its not a great codec, but its able to transcode, and Chrome/Edge supports it.
on the endpoint you are using to test with, reload pjsip and re-register the extension, and try again. If you hear the message then there is a problem with you opus codec. Its not complaining about the translation path… but its also not playing the audio.
It’s almost as if the playback stream is not being played out to an AUDIO object, our the audio object is muted. The demo page above allows you to select an output device, like speakers etc.
Thanks. Nice project.
I’m trying to learn the basics here…
Since you built around sipjs, I’m trying to make the basic demo (demo1) work on my server.
I can connect via wss, but (and I feel silly asking this) I then try to call my “200” extension in the “default” context.
The makeURI call to sip:200@mydomain.org doesn’t seem to work, and it syntactically fails on “200”. So by any chance do you know what the format would be here?
I’m not all that familiar with their solution, but the way they have probably build their system would be that you need to include all the sip: and the @domain stuff to make up a real SIP URL. (I find that annoying and not typical of user behaviour)
I have outlined these concepts in these two videos:
and (with PJSIP)
So the format of the dial will be as follows… If you register on a server say: asterisk.myserver.com, with username x and password y.
Once you are registered, anything you dial should then be: sip:200@asterisk.myserver.com (i’m using 200 as the example you provided)
This in turn fires the context that you have mapped to the endpoint. In your case you have:
context=default
so in your dial plan you should have a context
[default]
…
and this is what links one user to the other. (Its explained better in the videos).
[May 28 17:09:51] NOTICE[21245]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '"SIP.js Demo" <sip:anonymous.1n6io4@anonymous.invalid>' failed for 'my_client_ip_addr:52927' (callid: rkc7veh50sv7236cu98k) - No matching endpoint found
By the way, I tried your demo and was hoping to make a video call. Both of my SIP endpoints seem to support the codecs, and I have this for both in pjsip.conf: