Difference between revisions of "WebRTC"
| Line 27: | Line 27: | ||
Set proper path to TLS certificate in '''tlscertfile''' and private key in '''tlsprivatekey'''. | Set proper path to TLS certificate in '''tlscertfile''' and private key in '''tlsprivatekey'''. | ||
'''Example''' with Let's Encrypt: | |||
[general] | |||
enabled=yes | |||
bindaddr=0.0.0.0 | |||
bindport=8088 | |||
tlsenable=yes | |||
tlsbindaddr=0.0.0.0:8089 | |||
tlscertfile=/path/to/certificate | |||
tlsprivatekey=/path/to/private_key | |||
tlscertfile=/etc/letsencrypt/live/your.domain.com/fullchain.pem | |||
tlsprivatekey=/etc/letsencrypt/live/your.domain.com/privkey.pem | |||
2. Restart Asterisk: | 2. Restart Asterisk: | ||
Revision as of 06:34, 28 August 2025
WebRTC / WebSockets (WS/WSS)
WebRTC is supported from MOR X18 with PJSIP enabled.
Requirements
- Asterisk-20
- Rocky OS 9
- MOR X18 (or later)
- Domain in Asterisk server
- TLS (SSL) certificate
Enabling WebSockets
1. In Asterisk servers edit /etc/asterisk/http.conf and make sure that these settings are configured under [general] section:
[general] enabled=yes bindaddr=0.0.0.0 bindport=8088 tlsenable=yes tlsbindaddr=0.0.0.0:8089 tlscertfile=/path/to/certificate tlsprivatekey=/path/to/private_key
Note: these settings should be already present in http.conf, but commented out. Just uncomment required settings.
Set proper path to TLS certificate in tlscertfile and private key in tlsprivatekey.
Example with Let's Encrypt:
[general] enabled=yes bindaddr=0.0.0.0 bindport=8088 tlsenable=yes tlsbindaddr=0.0.0.0:8089 tlscertfile=/path/to/certificate tlsprivatekey=/path/to/private_key tlscertfile=/etc/letsencrypt/live/your.domain.com/fullchain.pem tlsprivatekey=/etc/letsencrypt/live/your.domain.com/privkey.pem
2. Restart Asterisk:
systemctl restart asterisk
3. Check if Asterisk HTTP server is running:
asterisk -rx "http show status"
The output should be similar to this:
HTTP Server Status: Prefix: Server: Asterisk/20 Server Enabled and Bound to 0.0.0.0:8088 HTTPS Server Enabled and Bound to 0.0.0.0:8089 Enabled URI's: /httpstatus => Asterisk HTTP General Status /ws => Asterisk HTTP WebSocket
The important lines are:
HTTPS Server Enabled and Bound to 0.0.0.0:8089 /ws => Asterisk HTTP WebSocket
If these are present, it means that Asterisk is configured to accept calls via WebSockets protocol.
4. Check if Asterisk is accepting HTTP requests:
In browser, open the following address (with your own domain name):
https://YOUR_DOMAIN:8089/httpstatus
The output should be similar to this:
If this page is shown, Asterisk is configured to work with WebSockets protocol and WebRTC calls can be initiated using address:
https://YOUR_DOMAIN:8089/ws
Enabling WebRTC in PJSIP Devices
Only PJSIP Devices are allowed to make WebRTC calls.
In PJSIP Device settings, enable WebRTC option under Advanced settings:
Tracing WebRTC calls
Since WebRTC calls are encrypted, it is difficult to capture calls directly using standard tools such as sngrep, wireshark, etc.
Asterisk allows to capture these calls using internal SIP logger by dumping UDP packets to PCAP file (even for encrypted calls) that can be later opened in sngrep or wireshark.
Enable SIP capture for all traffic
1. Run the following asterisk command to enable SIP logging:
asterisk -rx "pjsip set logger on"
2. Save output to PCAP file:
asterisk -rx "pjsip set logger pcap /root/asterisk_sip_capture.pcap
3. When done, disable SIP logging:
asterisk -rx "pjsip set logger off"
4. Open PCAP file wireshark or in sngrep by specifying input file:
sngrep -I /root/asterisk_sip_capture.pcap
Enable SIP capture for specific IPs
1. Run the following asterisk command to enable SIP logging for specific IP:
asterisk -rx "pjsip set logger host 192.168.0.111"
2. If needed, add additional IPs to capture (for example Provider IPs so that LegB side would be captured as well):
asterisk -rx "pjsip set logger host 192.168.0.222 add"
Note the additional keyword add at the end.
3. Save output to PCAP file:
asterisk -rx "pjsip set logger pcap /root/asterisk_sip_capture.pcap
4. When done, disable SIP logging:
asterisk -rx "pjsip set logger off"
5. Open PCAP file wireshark or in sngrep by specifying input file:
sngrep -I /root/asterisk_sip_capture.pcap
Testing with WebRTC phone
WIP
MOR X17 (or older) WebRTC/WebSockets/WSS
WebRTC together with MOR can be integrated using 3rd party solutions (Example: https://www.mizu-voip.com/Software/WebRTCtoSIP.aspx).
With Asterisk 1.8: Please note that only audio could work, because in our experience Asterisk 1.8 which MOR uses does not work properly with video over WebRTC.

