我一直在使用react、redux、节点媒体服务器和json 服务器开发这个类似Twitch 的应用程序。它允许用户通过将其 OBS 配置到服务器 URL 来直接流式传输视频/音频,并且流密钥等于在 React 应用程序中创建的流的 ID。您可以在您正在观看的流的结束 URL 上找到该信息。
您可以在以下位置查看我的完整存储库https://github.com/XorinNebulas/Streamy https://github.com/XorinNebulas/Streamy
您还可以在 Heroku 上查看我当前部署的网站版本:https://streamy-app.herokuapp.com/ https://streamy-app.herokuapp.com/
这是我位于streams/rtmpserver/index.js 中的节点媒体服务器的配置
const NodeMediaServer = require("node-media-server");
const HTTP_PORT = process.env.HTTP_PORT || 8000;
const config = {
rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 30,
ping_timeout: 60
},
http: {
port: HTTP_PORT,
allow_origin: "*"
}
};
var nms = new NodeMediaServer(config);
nms.run();
在本地运行项目时一切正常,我只需进入 OBS 流设置,使用 rtmp://localhost/live 的 URL,流密钥等于流的 ID。
但是,将我的节点应用程序部署到 Heroku 后,我不确定应该使用哪个服务器 URL。我还想指出,node-media-server 已在 Heroku 上成功运行。使用heroku logs --tail
我回来了
[INFO] Node Media Server v2.1.2
[1] 8/23/2019 17:22:22 78 [INFO] Node Media Rtmp Server started on port: 1935
[1] 8/23/2019 17:22:22 78 [INFO] Node Media Http Server started on port: 8000
[1] 8/23/2019 17:22:22 78 [INFO] Node Media WebSocket Server started on port: 8000
到目前为止,我已经尝试过简单的方法,例如通过将 localhost 替换为我的网站名称来修改 OBS 中的 URLrtmp://streamy-app.herokuapp.com/live
我希望我的 OBS 开始发布到端口 1935 上的 Heroku 部署的应用程序,但是在单击 OBS 中的开始流式传输后,我收到此消息
无法连接服务器
连接超时。确保您已配置有效的流媒体>服务并且没有防火墙阻止连接。
我真的很感激任何建议,我已经为此工作了几天。