Q: Why do I receive this error when I try to stream with WebRTC? “WebSocket connection failed”
A: There could be several different reasons the connection failed, all of which will throw that error.
Here is a troubleshooting checklist:
Step 1: First, you should enable WebRTC debugging in the webrtc Application.xml
Save and restart your WebRTC application for logs to file.
Step 2: Review your SSL and port 443 configuration
Encryption is required for all components of the WebRTC workflow, so you must have a secure HTTP (HTTPS) connection to a web camera for WebRTC publishing and playback.
Things to check:
- Your Wowza StreamLock cert. or self-signed cert. is still valid and hasn't expired.
- Port 443 is already in use. This port has to be open and used for SSL only.
- Check you have properly configured SSL with Streaming Engine.
- The StreamLock registered IP needs to be the host public IP.
The Wowza doc for troubleshooting SSL certificate issues is here.
Step 3: Make sure you have the proper ports open.
When configuring Wowza Streaming Engine to ingest or play streams with WebRTC, you must ensure that certain ports are accessible for client connections.
See Troubleshoot network errors for information about troubleshooting port configurations.
Step 4: Check you have enabled Engine for WebRTC publishing and playback.
If you have not already, you must enable WebRTC signaling for the SSL/TLS host port you configured with your SSL/TLS certificate to support an SDP exchange for the WebRTC session.
Enable in the Streaming Engine UI
Step 5: Check your ICE candidate setup.
Things to check:
- You selected either UDP(recommended) or TCP as the ICE candidate transport protocol.
- You need to change the IP address to the publicly-accessible Wowza Streaming Engine server IP address.
- For TCP candidates, you must specify a port to use for WebRTC streaming. The default streaming port for Wowza Streaming Engine is 1935. For UDP candidates, the port is dynamically assigned.
- If necessary, you can adjust the priority of the ICE candidate by using the up and down arrows in the UI or in the application.xml. Please see the instructions here.
At this time, NAT is not supported. A single STUN transport configuration must be used. TURN servers are not supported at this time.
We recommend disabling B-frames for WebRTC streams. With Wowza Streaming Engine 4.8.14 and later, the Transcoder adds B-frames by default. To disable B-frames, see Configure B-frame generation in Wowza Streaming Engine.
Step 6: Make sure your Signaling URL is correct.
For the Signaling URL, enter the secure WebSocket URL to connect to the Wowza Streaming Engine WebRTC sessions listener in the following format:
Things to check:
- If you are connecting WebRTC sessions using a port other than the default SSL/TLS port 443, you must include that non-standard port in the URL.
For example: wss://5ab43xxc0d123.streamlock.net:444/webrtc-session.json
Note! Because 443 is the port we use by default, you’ll need to edit and remove port 443 bound to your SSL, instead add the new port to configure it with your SSL certificate.
- If using Wowza StreamLock and the default SSL/TLS port (443), for example, the Signaling URL looks something like this: wss://5ab43xxc0d123.streamlock.net/webrtc-session.json.
- Your Application Name must match the WebRTC live application you configured.
- For Stream Name, you must enter a unique name for the stream.
Please review the WebRTC configuration steps here.
Step 7: Tune your Engine Server for optimal WebRTC streaming.
- You must tune the server to optimize transcoder memory utilization. When using Wowza Streaming Engine to perform transcoding, your memory utilization may get higher than expected. Under certain circumstances, this can cause out-of-memory issues and may result in server crashes.
- Full instructions to tune your Engine server are here.
Step 8: Click Save and Restart the application for any changes made.
- Changes you have made to any of your WebRTC applications or properties will not apply until you click save and restart the application.
Setup WebRTC streaming with Wowza Streaming Engine
Obtain a Wowza StreamLock SSL/TLS certificate for Free
Troubleshoot SSL/TLS certificate configuration
WebRTC Example pages for Publish and Playback
Control Access to WebRTC Publishing and Playback
How to Record WebRTC streams in Streaming Engine