【发布时间】:2018-07-06 21:43:48
【问题描述】:
帮助我使用 webRTC 库“peer.js”。为了让它工作,我需要一个我自己的服务器,所以我尝试在 evennode.com 上安装 peerjs。在托管设置中声明了启动命令 -> 自动检测(推荐)(如果 package.json 可用,您的应用程序将使用 npm start 启动。)。
所以我做了接下来的动作:
- 创建了我的新应用程序-> http://mypeerjs.eu-4.evennode.com/
- 从https://github.com/peers/peerjs-server解压并放入我的存储库的托管源
-
在那个包 .json 中有: “脚本”:{“测试”:“摩卡测试”,“开始”:“peerjs --port 9000 --key peerjs”} 我也试图说明(因为我是从本地服务器运行的)
"start": "bin/peerjs --port ${PORT:=9000}"
问题:应用程序没有启动。日志写下一个:
2018-01-27 18:41:41 102ea39d5429 ---> Starting app
2018-01-27 18:41:41 102ea39d5429 Detected package.json start script
2018-01-27 18:41:42 102ea39d5429
2018-01-27 18:41:42 102ea39d5429 > peer@0.2.8 start /data/app
2018-01-27 18:41:42 102ea39d5429 > peerjs --port 9000 --key peerjs
2018-01-27 18:41:42 102ea39d5429
2018-01-27 18:41:42 102ea39d5429 sh: 1: peerjs: not found
2018-01-27 18:41:42 102ea39d5429 npm ERR! peer@0.2.8 start: `peerjs --port 9000 --key peerjs`
2018-01-27 18:41:42 102ea39d5429 npm ERR! `sh "-c" "peerjs --port 9000 --key peerjs"` failed with 127
2018-01-27 18:41:42 102ea39d5429 npm ERR!
2018-01-27 18:41:42 102ea39d5429 npm ERR! Failed at the peer@0.2.8 start script.
2018-01-27 18:41:42 102ea39d5429 npm ERR! This is most likely a problem with the peer package,
2018-01-27 18:41:42 102ea39d5429 npm ERR! not with npm itself.
2018-01-27 18:41:42 102ea39d5429 npm ERR! Tell the author that this fails on your system:
2018-01-27 18:41:42 102ea39d5429 npm ERR! peerjs --port 9000 --key peerjs
2018-01-27 18:41:42 102ea39d5429 npm ERR! You can get their info via:
2018-01-27 18:41:42 102ea39d5429 npm ERR! npm owner ls peer
2018-01-27 18:41:42 102ea39d5429 npm ERR! There is likely additional logging output above.
2018-01-27 18:41:42 102ea39d5429
2018-01-27 18:41:42 102ea39d5429 npm ERR! System Linux 3.10.0-693.5.2.el7.x86_64
2018-01-27 18:41:42 102ea39d5429 npm ERR! command "/data/n/bin/node" "/data/n/bin/npm" "start"
2018-01-27 18:41:42 102ea39d5429 npm ERR! cwd /data/app
2018-01-27 18:41:42 102ea39d5429 npm ERR! node -v v0.9.1
2018-01-27 18:41:42 102ea39d5429 npm ERR! npm -v 1.1.59
2018-01-27 18:41:42 102ea39d5429 npm ERR! code ELIFECYCLE
2018-01-27 18:41:42 102ea39d5429 npm ERR!
2018-01-27 18:41:42 102ea39d5429 npm ERR! Additional logging details can be found in:
2018-01-27 18:41:42 102ea39d5429 npm ERR! /data/app/npm-debug.log
2018-01-27 18:41:42 102ea39d5429 npm ERR! not ok code 0
在我的本地服务器上部署成功
我解压了存档,移到<path_to_peerjs-server>/bin 并使用了一行来使用节点运行它:
node peerjs --port 9000 --key peerjs
我的家庭网络中的服务器成功运行,浏览器对等体相互连接,一切正常。
HERE IS THE LOG FROM LOCAL SERVER
但在托管它没有所以我请求你的帮助。
在日志中,正如我得到的,有一个错误
18:41:42 102ea39d5429 npm 错误! peerjs --port 9000 --key peerjs
感谢您的提前!
编辑我将应用程序上传到我的托管服务器:
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello world!');
});
server.listen(process.env.PORT);
它有效,你可能会看到它。 我觉得问题在于侦听器端口打开
【问题讨论】:
标签: node.js server webrtc hosting peerjs