首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >到'ws://localhost:5080/live/?id=mystream‘的WebSocket连接失败- red5pro

到'ws://localhost:5080/live/?id=mystream‘的WebSocket连接失败- red5pro
EN

Stack Overflow用户
提问于 2021-11-04 10:44:44
回答 1查看 205关注 0票数 0

我需要在本地广播我的蒸汽,以供开发之用。但是错误来了。我是媒体服务器的新手。我只想把red5pro媒体服务器集成到我的网站上进行多个广播。目前,我从youtube上跟踪Red5pro发布者文档本教程,将red5probeginner测试到媒体服务器上。这个教程有点过时,但是我仍然在关注它,因为我没有找到任何其他的red5pro教程。

我使用("python -m http.server 8000")来运行本地服务器,这在视频教程中已经讲过了。

我的html代码->

代码语言:javascript
复制
<!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:函数(E){返回新的WebSocket(e) }

我认为它不能创建websocket!

EN

回答 1

Stack Overflow用户

发布于 2021-11-05 13:22:31

我不是HTML5 SDK的专家,但我看到您已经将媒体设置和其他几行注释掉了;取消注释,然后再试一次。还可以查看服务器上的red5.log,寻找其他线索;任何异常触发都会有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69837977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档