CUCM v11与Briker 1.2环境下,能否用Asterisk实现浏览器直拨电话?
Absolutely! Asterisk is exactly what you need here—it natively supports WebRTC, which lets modern browsers (Chrome, Firefox, Edge, etc.) initiate and receive calls directly via JavaScript, no softphone or desktop app required. Here’s a practical breakdown of how to make this work with your existing systems:
1. Core Setup: Asterisk + WebRTC
First, configure Asterisk to handle WebRTC connections. We recommend using PJSIP (Asterisk’s modern SIP stack) over the older chan_sip for better compatibility:
- In
pjsip.conf, define a WebRTC endpoint with secure WebSocket (WSS) transport and SRTP for media encryption:[webrtc_endpoint] type=endpoint transport=wss_transport context=from_webrtc disallow=all allow=opus,ulaw auth=webrtc_auth aors=webrtc_aor webrtc=yes - Add a WSS transport to listen for browser connections:
[wss_transport] type=transport protocol=wss bind=0.0.0.0:8089 - Don’t forget to set up authentication (
auth) and address of record (aors) sections inpjsip.conffor your WebRTC users.
2. Integrate with CUCM v11
To route calls between browser endpoints and CUCM-registered extensions, use a SIP trunk:
- In CUCM, create a new SIP trunk under Call Routing > SIP Trunks. Point it to your Asterisk server’s IP, set matching codecs (Opus/u-law), and configure dial rules to route calls to Asterisk.
- In Asterisk, add a SIP trunk endpoint in
pjsip.confthat points to CUCM. Use this trunk to route calls from WebRTC endpoints to CUCM extensions, and vice versa. - For small-scale setups, you can also have Asterisk register as a SIP extension with CUCM for simpler configuration.
3. Integrate with Briker 1.2
Briker is a Linux-based PBX, so integration follows the same SIP trunk pattern:
- Configure a SIP trunk on Briker that points to your Asterisk server. Most PBXs have a straightforward trunk setup menu—just input Asterisk’s IP, authentication details, and supported codecs.
- Mirror this setup in Asterisk’s
pjsip.confto create a trunk endpoint for Briker. This lets you route calls between WebRTC browsers and Briker-registered extensions seamlessly.
4. Connect to PSTN
Asterisk can bridge browser calls to the PSTN in two main ways:
- SIP Trunk with a PSTN Provider: This is the most modern, scalable option. Sign up for a SIP trunk from a provider, configure it in Asterisk, and set up dial plans to route outbound calls to the PSTN and inbound calls to your WebRTC endpoints.
- Analog/PRI Gateway: If you have existing PSTN lines (analog or PRI), use a gateway device (like Digium cards) to connect them to Asterisk. Configure Asterisk’s
chan_dahdimodule to handle these lines.
5. Build the Browser Interface
You’ll need a simple web page with JavaScript to handle call control. Use native WebRTC APIs or a lightweight library like simple-webrtc to connect to Asterisk’s WSS endpoint:
- Example snippet to connect and initiate a call:
// Connect to Asterisk's WSS endpoint const socket = new WebSocket('wss://your-asterisk-ip:8089/ws'); // Register the browser with Asterisk once connected socket.onopen = () => { socket.send(JSON.stringify({ command: 'register', username: 'webrtc_user_1', password: 'your_secure_password' })); }; // Function to dial a number (CUCM extension, Briker extension, or PSTN number) function dialNumber(number) { socket.send(JSON.stringify({ command: 'originate', endpoint: 'webrtc_endpoint', destination: number })); } - For advanced features (hold, transfer, call history), use Asterisk’s ARI (Asterisk REST Interface) to interact with call sessions via HTTP requests.
Key Considerations
- Security: Always use WSS instead of unencrypted WS, and enforce SRTP for media streams to protect call privacy.
- Codecs: Ensure all systems (Asterisk, CUCM, Briker, browsers) support common codecs like Opus or u-law to avoid audio glitches.
- Network: Make sure your firewall allows traffic on port 8089 (WSS) between browsers and Asterisk. For WebRTC media, set up STUN/TURN in Asterisk to handle NAT traversal.
内容的提问来源于stack exchange,提问作者Yohanes AI

