How to Resolve “WebRTC Error: WebSocket Connection Failed” in Wowza Streaming Engine

If you’re encountering the “WebSocket connection failed” error in WebRTC, several issues could be causing it. Follow these steps to troubleshoot and resolve the problem.

Common Issues and Quick Fixes

  • Expired Certificate: Renew your SSL certificate.
  • Port Blocked: Open port 443 in your firewall settings.
  • Incorrect Signaling URL: Double-check the URL format and domain.

1. Enable WebRTC Debugging

Enable debugging to get detailed logs that can help identify the issue.

First, you should enable WebRTC debugging in the webrtc Application.xml located in
[install-dir]/conf/webrtc.

<Property>
    <Name>webrtcDebugLog</Name>
    <Value>true</Value>
    <Type>Boolean</Type>
</Property>

Save and restart your WebRTC application for logs to file.

2. Review SSL and Port 443 Configuration

Ensure all WebRTC components use encryption. You need a secure HTTPS connection for WebRTC publishing and playback.

Things to Check:

  • Certificate Validity: Ensure your Wowza StreamLock or self-signed certificate is valid.
  • Port 443: Confirm port 443 is open and used only for SSL.
  • SSL Configuration: Verify SSL is properly configured in Wowza Streaming Engine.
  • Public IP: The StreamLock registered IP should be the host’s public IP.

Review the Wowza SSL Troubleshooting Guide

3. Check Open Ports

Ensure the necessary ports are open and not blocked by a firewall. Review the  Troubleshoot Network Errors article for more ideas.

4. Enable WebRTC in Streaming Engine

Make sure WebRTC is enabled in the Wowza Streaming Engine settings.

Enable in the Streaming Engine UI

Enable in the application.xml

5. Verify ICE Candidate Setup

Check that your Interactive Connectivity Establishment (ICE) candidates are correctly configured. 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. 

Currently, 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.

6. Confirm Signaling URL

Ensure the signaling URL is correctly set up.

Example: wss://your-domain.com:443/webrtc-session.json

Things to check:

  • If you connect WebRTC sessions using a port other than the default SSL/TLS port 443, you must include that 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.
  • Your Application Name must match the WebRTC live application you configured.
  • For Stream Name, you must enter a unique name for the stream.

    Review the WebRTC configuration steps here. 

7. Tune Engine Server

Adjust the server settings to optimize performance for WebRTC.

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. 

8. Save and Restart

After making changes, save your settings and restart the Wowza Streaming Engine.

Additional Resources

For more detailed troubleshooting, refer to these resources:

Obtain a Wowza StreamLock SSL/TLS certificate for Free

Troubleshoot SSL/TLS certificate configuration

WebRTC Port Configuration

WebRTC Example pages for Publish and Playback

Control Access to WebRTC Publishing and Playback

How to Record WebRTC streams in Streaming Engine