webRTC implementation in asterisk

Hello,
I’m setting up an asterisk server to use between a raspberry and a flutter app.
I did it by implementig websocket transport in my pjsip.conf. I have logs that tells me it is ringing and I can see it in my app but when I answer the call, asterisk tells me everyone is busy. Because flutter may require dtls, I wanted to add a dtls config to my configuration but my phone can’t register. This are my config files:
// pjsip.conf
[general]
[transport-ws]
type=transport
protocol=ws
bind=0.0.0.0
allow_reload=yes

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
allow_reload=yes
tos=cs3
cos=3

[0645361771]
type=aor
max_contacts=1
remove_existing=yes

[0645361771-auth]
type=auth
auth_type=userpass
password=test
username=0645361771

[0645361771]
type=endpoint
aors=0645361771
auth=0645361771-auth
transport=transport-ws
context=diese
use_avpf=yes
media_encryption=dtls
dtls_ca_file=/etc/asterisk/keys/asterisk.crt
dtls_cert_file=/etc/asterisk/keys/asterisk.pem
dtls_private_key=/etc/asterisk/keys/asterisk.key
dtls_verify=fingerprint
dtls_setup=actpass
dtls_fingerprint=SHA-256
ice_support=yes
media_use_received_transport=yes
rtcp_mux=yes
disallow=all
allow=opus
allow=ulaw

[109]
type=aor
max_contacts=1
remove_existing=yes

[109-auth]
type=auth
auth_type=userpass
username=109
password=test

[109]
type=endpoint
aors=109
auth=109-auth
transport=transport-udp
context=diese
use_avpf=yes
dtls_ca_file=/etc/asterisk/keys/asterisk.crt
dtls_cert_file=/etc/asterisk/keys/asterisk.pem
dtls_private_key=/etc/asterisk/keys/asterisk.key
dtls_verify=fingerprint
dtls_setup=actpass
dtls_fingerprint=SHA-256
ice_support=yes
media_use_received_transport=yes
rtcp_mux=yes
disallow=all
allow=opus
allow=ulaw

// extensions.conf
[diese]
exten => _X.,1,Dial(PJSIP/${EXTEN})

you need to define what this means, what happens, such as if the traffic even appears at Asterisk (pjsip set logger on).

Well the asterisk logs tells me that the request REGISTER has failed because of no matching endpoints and failed to authenticate

That would mean something in your configuration caused it to fail to load, which would be output on the console at Asterisk start time. The following:

use_avpf=yes
dtls_ca_file=/etc/asterisk/keys/asterisk.crt
dtls_cert_file=/etc/asterisk/keys/asterisk.pem
dtls_private_key=/etc/asterisk/keys/asterisk.key
dtls_verify=fingerprint
dtls_setup=actpass
dtls_fingerprint=SHA-256
ice_support=yes
media_use_received_transport=yes
rtcp_mux=yes

Can also be replaced with:

webrtc=yes

Which will also automatically create an ephemeral DTLS certificate.

1 Like

Thanks a lot for your responses. Actually it works I can register and the communication begins but only in one way. The audio only transfert from the raspberry (udp) to my flutter app (ws). If you have an idea for this bug.

It’s not a bug but a network problem. In asterisk set rtp debug on and see if you have rtp traffic as it should. You could also run tcpdump on your raspberry to see if rtp is going in and out. Finally check your firewall/router/… if you have something related to SIP activated like ALG for example.

After turning on the rtp debug, I also see that it gets data from the raspberry and send it to the app but not the opposite. I will check if this comes from the socket handling in the app.

after checking with wireshark, from the app to the raspberry I have an “unreachable port” error. this is my rtp.conf :
[general]
rtpstart=10000
rtpend=50000
icesupport=true

and this is the log from asterisk during a call :
Executing [0645361771@diese:1] Dial(“PJSIP/106-00000000”, “PJSIP/0645361771”) in new stack
– Called PJSIP/0645361771
– PJSIP/0645361771-00000001 is ringing
> 0x7f60fc0508b0 – Strict RTP learning after remote address set to: 46.218.10.43:45419
– PJSIP/0645361771-00000001 answered PJSIP/106-00000000
> 0x7f60fc011f90 – Strict RTP learning after remote address set to: 172.16.1.6:4008
– Channel PJSIP/0645361771-00000001 joined ‘simple_bridge’ basic-bridge
– Channel PJSIP/106-00000000 joined ‘simple_bridge’ basic-bridge
> 0x7f60fc0508b0 – Strict RTP learning after ICE completion
> 0x7f60fc0508b0 – Strict RTP learning after remote address set to: 46.218.10.43:45419
> 0x7f60fc011f90 – Strict RTP qualifying stream type: audio
> 0x7f60fc011f90 – Strict RTP switching source address to 178.33.26.236:4008
> 0x7f60fc0508b0 – Strict RTP switching to RTP target address 46.218.10.43:45419 as source
> 0x7f60fc011f90 – Strict RTP learning complete - Locking on source address 178.33.26.236:4008
> 0x7f60fc0508b0 – Strict RTP learning complete - Locking on source address 46.218.10.43:45419

These are the Asterisk side port numbers, but the numbers in the log are those for the remote side.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.