How separate server from client I got err net::ERR_NAME_NOT_RESOLVED

85 views
Skip to first unread message

alf...@dashboardhosting.com

unread,
Feb 26, 2019, 12:54:10 PM2/26/19
to EasyRTC
Hi to all I am new in this, I try to separate the server from my client I don't want to use static files but I receiver from socket
socket.io.js:2 GET http://file/socket.io/?EIO=3&transport=polling&t=Magx0bH net::ERR_NAME_NOT_RESOLVED

I don't know if this the way to get done this, please can someone help me out

this is my client

$(document).ready(function () {
io.connect('https://10.0.0.98:8443');

var selfEasyrtcid = "";

connect();

function disable(domId) {
document.getElementById(domId).disabled = "disabled";
}
function enable(domId) {
document.getElementById(domId).disabled = "";
}
function connect() {
easyrtc.enableDebug(false);
console.log("Initializing.");
easyrtc.enableAudio(false);
easyrtc.enableAudioReceive(false);
easyrtc.setRoomOccupantListener(convertListToButtons);
easyrtc.initMediaSource(
function(){ // success callback
var selfVideo = document.getElementById("local");
easyrtc.setVideoObjectSrc(selfVideo, easyrtc.getLocalStream());
easyrtc.connect("easyrtc.videoOnly", loginSuccess, loginFailure);
},
function(errorCode, errmesg){
easyrtc.showError("MEDIA-ERROR", errmesg);
} // failure callback
);
}
function terminatePage() {
easyrtc.disconnect();
}
function hangup() {
easyrtc.hangupAll();
disable("hangupButton");
}
function clearConnectList() {
var otherClientDiv = document.getElementById("otherClients");
while (otherClientDiv.hasChildNodes()) {
otherClientDiv.removeChild(otherClientDiv.lastChild);
}
}
function convertListToButtons (roomName, occupants, isPrimary) {
clearConnectList();
var otherClientDiv = document.getElementById("otherClients");
for(var easyrtcid in occupants) {
var button = document.createElement("button");
button.onclick = function(easyrtcid) {
return function() {
performCall(easyrtcid);
};
}(easyrtcid);
var label = document.createTextNode( easyrtc.idToName(easyrtcid));
button.appendChild(label);
otherClientDiv.appendChild(button);
}
if( !otherClientDiv.hasChildNodes() ) {
otherClientDiv.innerHTML = "<em>Nobody else is on...</em>";
}
}
function performCall(otherEasyrtcid) {
easyrtc.hangupAll();
var acceptedCB = function(accepted, easyrtcid) {
if( !accepted ) {
easyrtc.showError("CALL-REJECTED", "Sorry, your call to " + easyrtc.idToName(easyrtcid) + " was rejected");
enable("otherClients");
}
};
var successCB = function() {
enable("hangupButton");
};
var failureCB = function() {
enable("otherClients");
};
easyrtc.call(otherEasyrtcid, successCB, failureCB, acceptedCB);
}
function loginSuccess(easyrtcid) {
disable("connectButton");
// enable("disconnectButton");
enable("otherClients");
selfEasyrtcid = easyrtcid;
document.getElementById("iam").innerHTML = "I am " + easyrtcid;
}
function loginFailure(errorCode, message) {
easyrtc.showError(errorCode, message);
}
function disconnect() {
document.getElementById("iam").innerHTML = "logged out";
easyrtc.disconnect();
console.log("disconnecting from server");
enable("connectButton");
// disable("disconnectButton");
clearConnectList();
easyrtc.setVideoObjectSrc(document.getElementById("selfVideo"), "");
}
easyrtc.setStreamAcceptor( function(easyrtcid, stream) {
var video = document.getElementById("callerVideo");
easyrtc.setVideoObjectSrc(video,stream);
console.log("saw video from " + easyrtcid);
enable("hangupButton");
});
easyrtc.setOnStreamClosed( function (easyrtcid) {
easyrtc.setVideoObjectSrc(document.getElementById("callerVideo"), "");
disable("hangupButton");
});
easyrtc.setAcceptChecker(function(easyrtcid, callback) {
document.getElementById("acceptCallBox").style.display = "block";
if( easyrtc.getConnectionCount() > 0 ) {
document.getElementById("acceptCallLabel").innerHTML = "Drop current call and accept new from " + easyrtc.idToName(easyrtcid) + " ?";
}
else {
document.getElementById("acceptCallLabel").innerHTML = "Accept incoming call from " + easyrtc.idToName(easyrtcid) + " ?";
}
var acceptTheCall = function(wasAccepted) {
document.getElementById("acceptCallBox").style.display = "none";
if( wasAccepted && easyrtc.getConnectionCount() > 0 ) {
easyrtc.hangupAll();
}
callback(wasAccepted);
};
document.getElementById("callAcceptButton").onclick = function() {
acceptTheCall(true);
};
document.getElementById("callRejectButton").onclick =function() {
acceptTheCall(false);
};
} );

});


this is my server 

// Load required modules
var https = require("https"); // https server core module
var fs = require("fs"); // file system core module
var express = require("express"); // web framework external module
var io = require("socket.io"); // web socket external module
var ip = require("ip");

// This sample is using the easyrtc from parent folder.
// To use this server_example folder only without parent folder:
// 1. you need to replace this "require("../");" by "require("easyrtc");"
// 2. install easyrtc (npm i easyrtc --save) in server_example/package.json

var easyrtc = require("easyrtc"); // EasyRTC internal module

// Setup and configure Express http server. Expect a subfolder called "static" to be the web root.
var httpApp = express();
// httpApp.use(express.static(__dirname + "/static/"));
httpApp.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});

// Start Express https server on port 8443
var webServer = https.createServer({
key: fs.readFileSync(__dirname + "/certs/localhost.key"),
cert: fs.readFileSync(__dirname + "/certs/localhost.crt")
}, httpApp);

// Start Socket.io so it attaches itself to Express server
var socketServer = io.listen(webServer, {"log level":1});
socketServer.on('connection',function() {
console.log('user conected')
});

// Start EasyRTC server
var rtc = easyrtc.listen(httpApp, socketServer);

// Listen on port 8443
webServer.listen(8443,ip.address(), function () {
console.log(`listening on https://${ip.address()}:8443`);
});

alf...@dashboardhosting.com

unread,
Feb 26, 2019, 1:08:13 PM2/26/19
to EasyRTC
well I thing this is my solution easyrtc.setSocketUrl("https://my_address:8443");
Reply all
Reply to author
Forward
0 new messages