0

I need to broadcast my steam in localhost for developing purposes. But the error comes in. I am new to media servers. I just wanna integrate the red5pro media server for one to many broadcasting in my website. I am currently following Red5pro Publisher Docs and this tutorial from youtube for testing red5pro[beginner to media servers]. The tutorial is little outdated but i am still following it because i didn't find any other tutorial for red5pro.

I am using python simplehttpserver ("python -m http.server 8000") to run local server as told in the video tutorial.

My html code ->

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="video-container">
        <video id="red5pro-publisher"></video>
    </div>
    <script src="lib/red5pro/red5pro-sdk.min.js"></script>
    <script>
        // Create a new instance of the WebRTC publisher.
        var publisher = new red5prosdk.RTCPublisher();

        // Create a view instance based on video element id.
        var view = new red5prosdk.PublisherView('red5pro-publisher');
        view.attachPublisher(publisher);

        // Access user media.
        navigator.getUserMedia({
            audio: true,
            video: true
        }, function (media) {

            // Upon access of user media,
            // 1. Attach the stream to the publisher.
            // 2. Show the stream as preview in view instance.
            publisher.attachStream(media);
            view.preview(media, true);

        }, function (error) {
            console.error(error);
        });

        // Using Chrome/Google TURN/STUN servers.
        var iceServers = [{ urls: 'stun:stun2.l.google.com:19302' }];

        // Initialize
        publisher.init({
            protocol: 'ws',
            host: 'localhost',
            port: 8081,
            app: 'live',
            streamName: 'mystream',
            iceServers: iceServers,
            tcpMuxPolicy: 'negotiate'
        })
            .then(function () {
                // Invoke the publish action
                return publisher.publish();
            })
            .catch(function (error) {
                // A fault occurred while trying to initialize and publish the stream.
                console.error(error);
            });
    </script>
</body>
<!-- WebRTC Shim -->
<!-- <script src="https://webrtc.github.io/adapter/adapter-latest.js"></script> -->
<!-- Exposes `red5prosdk` on the window global. -->
</html>

The error ->

  1. enter image description here

  2. red5pro-sdk.min.js 158th line -->
    createWebSocket: function(e) { return new WebSocket(e) }

I think it is not able to create websocket!!

Prems Finance
  • 57
  • 1
  • 8

1 Answers1

0

I'm not an expert on the HTML5 SDK, but I see you have the media settings and a few other lines commented out; uncomment them and try again. Also look through your red5.log on the server for other clues; any exceptions firing would be helpful.

Paul Gregoire
  • 9,715
  • 11
  • 67
  • 131
  • I have already tried by uncommenting the parameters but found the same error . I am only able to find this error in browser's console :( . - Beginner in media servers - – Prems Finance Nov 05 '21 at 16:22
  • Whats in your server log? Also, make sure you don't share your license key, if you have one. – Paul Gregoire Nov 06 '21 at 17:34
  • I am using python simplehttpserver ("python -m http.server 8000") to run local server as told in the video tutorial that's why there is nothing useful showing in server logs. --servers logs---> 127.0.0.1 - - [07/Nov/2021 21:38:00] "GET / HTTP/1.1" 304 - 127.0.0.1 - - [07/Nov/2021 21:38:00] "GET /red5pro-sdk.min.js HTTP/1.1" 304 - 127.0.0.1 - - [07/Nov/2021 21:38:00] "GET /main.js HTTP/1.1" 200 - <---- – Prems Finance Nov 07 '21 at 16:15
  • If you have red5 running on port 5080 and python simple server on 8000, what you have above should connect. The video is a little out-of-date, but it should be mostly accurate. – Paul Gregoire Nov 10 '21 at 03:38
  • it also says that - something is wrong in ("createWebSocket @ red5pro-sdk.min.js:158") 158th line of red5pro-sedk.min.js. I think that it is failing to create websocket. red5pro-sdk.min.js- 158th line --> createWebSocket: function(e) { return new WebSocket(e) }, – Prems Finance Nov 10 '21 at 03:45