【问题标题】:WebSocket connection to 'ws://localhost:5080/live/?id=mystream' failed - red5proWebSocket 连接到 'ws://localhost:5080/live/?id=mystream' 失败 - red5pro
【发布时间】:2021-11-04 10:44:44
【问题描述】:

出于开发目的,我需要在 localhost 中广播我的 Steam。但是错误出现了。我是媒体服务器的新手。我只想在我的网站上集成 red5pro 媒体服务器以进行一对多广播。 我目前正在关注来自 youtube 的 Red5pro Publisher Docsthis tutorial 以测试 red5pro [媒体服务器初学者]。该教程有点过时,但我仍在关注它,因为我没有找到任何其他 red5pro 教程。

我正在使用 python simplehttpserver ("python -m http.server 8000") 按照视频教程中的说明运行本地服务器。

我的html代码->

<!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>

错误->

  1. red5pro-sdk.min.js 第 158 行 -->
    createWebSocket: function(e) { return new WebSocket(e) }

我认为它无法创建 websocket!

【问题讨论】:

    标签: javascript server red5 red5pro windows-media-server


    【解决方案1】:

    我不是 HTML5 SDK 方面的专家,但我看到您已将媒体设置和其他几行注释掉;取消注释并重试。还可以查看服务器上的 red5.log 以获取其他线索;任何异常触发都会有所帮助。

    【讨论】:

    • 我已经尝试取消注释参数但发现相同的错误。我只能在浏览器的控制台中找到此错误:(。-媒体服务器中的初学者-
    • 您的服务器日志中有什么内容?此外,请确保您没有共享您的许可证密钥(如果有)。
    • 我正在使用 python simplehttpserver ("python -m http.server 8000") 来运行本地服务器,如视频教程中所述,这就是为什么服务器日志中没有任何有用的显示。 --服务器日志---> 127.0.0.1 - - [2021 年 11 月 7 日 21:38:00] “GET / HTTP/1.1” 304 - 127.0.0.1 - - [2021 年 11 月 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 -
    • 如果您在端口 5080 上运行 red5 并且在 8000 上运行 python 简单服务器,则上述内容应该可以连接。该视频有点过时,但应该是准确的。
    • 它还说 - red5pro-sedk.min.js 的第 158 行 ("createWebSocket @ red5pro-sdk.min.js:158") 有问题。我认为它无法创建 websocket。 red5pro-sdk.min.js- 第 158 行 --> createWebSocket: function(e) { return new WebSocket(e) },
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    • 2023-01-30
    • 2022-07-14
    • 1970-01-01
    • 2020-04-07
    相关资源
    最近更新 更多