在Xirsys中获取Ice Config时出错 [英] Error on getting Ice Config in Xirsys

查看:155
本文介绍了在Xirsys中获取Ice Config时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找错误时遇到了麻烦,有人可以为我指出吗,请问我已经参加了2天,但仍然无法解决.

I'm having a trouble on looking for the error can anyone point it out for me please i have been into this for 2 days and still can't figure it out.

上面的图片是来自heroku的错误日志.

the picture above is the error log from heroku.

这是我的 server.js ,用于Ice配置

and here is my server.js for the ice configuration

// 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"的子文件夹作为网络根目录.

// Setup and configure Express http server. Expect a subfolder called "static" to be the web root.

var app = express();

app.use(serveStatic('public', {'index': ['index.html']}));

var port = process.env.PORT || 8080;

//在端口8080上启动Express http服务器

// Start Express http server on port 8080

var webServer = http.createServer(app).listen(port);

//启动Socket.io,以便将其自身附加到Express服务器

// Start Socket.io so it attaches itself to Express server

var socketServer = socketIo.listen(webServer, {"log level":1});




easyrtc.setOption("logLevel", "debug");

//覆盖默认的easyrtcAuth侦听器,仅使我们可以直接访问其回调

// Overriding the default easyrtcAuth listener, only so we can directly access its callback

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);
});
});

//要进行测试,让我们为每个房间加入打印凭证到控制台!

// To test, lets print the credential to the console for every room join!

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服务器

// Start EasyRTC server

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配置easyrtc

//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上监听

//listen on port 8080

webServer.listen(8080, function () {

console.log('listening on http://localhost:'+port);
});

推荐答案

通过添加另一个模块

var request = require("request");

并编辑我的制冰服务器

request.post('https://service.xirsys.com/ice',{
    form:{
        ident: "****",
        secret: "****",
        domain: "****",
        application: "****",
        room: "****",
        secure: 1
    },
    json:true
 },

我获得让它起作用的方法:)

i obtain to let it work :)

这篇关于在Xirsys中获取Ice Config时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆