我想在 Heroku 上部署一个 webRTC 信令服务器。它适用于我的本地机器,但给出了:
Error: getaddrinfo ENOTFOUND global.xirsys.net global.xirsys.net`
当部署在 Heroku 上时。
我正在使用 simpleWebRTC + signalmaster + XirSys
xirSys 的官方文档显示:
// Node Get ICE STUN and TURN list
var https = require("https");
var options = {
host: "global.xirsys.net",
path: "/_turn/Acumany",
method: "PUT",
headers: {
"Authorization": "Basic " + new Buffer("acumany:4b6aea04-6152-11e7-9d16-3fa9b82ffd4f").toString("base64")
}
};
var httpreq = https.request(options, function(httpres) {
var str = "";
httpres.on("data", function(data){ str += data; });
httpres.on("error", function(e){ console.log("error: ",e); });
httpres.on("end", function(){
console.log("ICE List: ", str);
});
});
httpreq.end();
我使用了 axios:
axios.put("https://acumany:4b6aea04-6152-11e7-9d16-3fa9b82ffd4f@global.xirsys.net/_turn/Acumany")
.then((res) => {
var result = res.data;
var iceServers = result.v.iceServers;
var turnservers = [],
stunservers = [];
iceServers.forEach(function (server) {
if(server.url.indexOf("stun:") != -1){
stunservers.push(server);
}else{
turnservers.push(server);
}
});
console.log("emitting server info => ", stunservers, turnservers);
client.emit('stunservers', stunservers || []);
client.emit('turnservers', turnservers);
})
.catch(function (err) {
console.log("axios error => ", err);
});
我的猜测是 heroku 在自己的负载均衡器中切换 http/https。如何更改此代码以使其正常工作?(使用 https 或 axios)