我在寻找错误方面遇到麻烦,任何人都可以为我指出这一点,我已经进入了2天,仍然无法弄明白。
上面的图片是heroku的错误日志。
这是我的 server.js ,用于ice配置
// Load required modules
var http = require("http"); // http server core module
var https = require('https');
var express = require("express"); // web framework external module
var serveStatic = require('serve-static'); // serve static files
var socketIo = require("socket.io"); // web socket external module
var easyrtc = require('./lib/easyrtc_server'); // EasyRTC external module
// Set process name
process.title = "node-easyrtc";
//设置并配置Express http服务器。期望一个名为“static”的子文件夹成为Web根目录。
var app = express();
app.use(serveStatic('public', {'index': ['index.html']}));
var port = process.env.PORT || 8080;
//在端口8080上启动Express http服务器
var webServer = http.createServer(app).listen(port);
//启动Socket.io,使其自身附加到Express服务器
var socketServer = socketIo.listen(webServer, {"log level":1});
easyrtc.setOption("logLevel", "debug");
//覆盖默认的easyrtcAuth侦听器,只有这样我们才能直接访问其回调
easyrtc.events.on("easyrtcAuth", function(socket, easyrtcid, msg, socketCallback, callback) {
easyrtc.events.defaultListeners.easyrtcAuth(socket, easyrtcid, msg, socketCallback, function(err, connectionObj){
if (err || !msg.msgData || !msg.msgData.credential || !connectionObj)
{
callback(err, connectionObj);
return;
}
connectionObj.setField("credential", msg.msgData.credential, {"isShared":false});
console.log("["+easyrtcid+"] Credential saved!", connectionObj.getFieldValueSync("credential"));
callback(err, connectionObj);
});
});
//要进行测试,我们可以将凭证打印到控制台,以便每个房间加入!
easyrtc.events.on("roomJoin", function(connectionObj, roomName, roomParameter, callback) {
console.log("["+connectionObj.getEasyrtcid()+"] Credential retrieved!", connectionObj.getFieldValueSync("credential"));
easyrtc.events.defaultListeners.roomJoin(connectionObj, roomName, roomParameter, callback);
});
//启动EasyRTC服务器
var rtc = easyrtc.listen(app, socketServer, null, function(err, rtcRef) {
console.log("Initiated");
rtcRef.events.on("roomCreate", function(appObj, creatorConnectionObj, roomName, roomOptions, callback) {
console.log("roomCreate fired! Trying to create: " + roomName);
appObj.events.defaultListeners.roomCreate(appObj, creatorConnectionObj, roomName, roomOptions, callback);
});
});
// ice config easyrtc
easyrtc.on("getIceConfig", function(connectionObj, callback) {
// This object will take in an array of XirSys STUN and TURN servers
var iceConfig = [];
http.request({
url: 'https://service.xirsys.com/ice',
qs: {
ident: "***",
secret: "****",
domain: "***",
application: "test-livestream",
room: "test-livestream-room",
secure: 1
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
// body.d.iceServers is where the array of ICE servers lives
iceConfig = body.d.iceServers;
console.log(iceConfig);
callback(null, iceConfig);
}
else
{
console.log(error);
}
}
});
});
//侦听端口8080
webServer.listen(8080, function () {
console.log('listening on http://localhost:'+port);
});
答案 0 :(得分:0)
添加另一个模块
var request = require("request");
并编辑我的冰服务器
request.post('https://service.xirsys.com/ice',{
form:{
ident: "****",
secret: "****",
domain: "****",
application: "****",
room: "****",
secure: 1
},
json:true
},
我获得让它工作:)