2016-08-08 21 views
1

サーバー上でwebrtc/socket.io/nodejsを実行していますが、https://domain.com:8080に行ってビデオ会議をテストするとすべて正常に動作します。socket.io 404 cant with socket.io server

しかし、私は、スクリプトが私のウェブサーバ/ public_htmlの/

で実行したいが、私はそれが8080サーバーに接続していない理由を知りません。

私のサーバー(server.js)デWEBサーバ上の

// Load required modules 
var https = require("https");    // http server core module 
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("../"); 
const fs = require('fs');   // EasyRTC external module 

const options = { 
    key: fs.readFileSync('key.pem'), 
    cert: fs.readFileSync('cert.pem') 
}; 

// Set process name 
process.title = "node-easyrtc"; 

// Setup and configure Express http server. Expect a subfolder called "static" to be the web root. 
var app = express(); 
app.use(serveStatic('static', {'index': ['index.html']})); 

// Start Express http server on port 8080 
var webServer = https.createServer(options, app).listen(8080); 

// Start Socket.io so it attaches itself to Express server 
var socketServer = socketIo.listen(webServer, {"log level":1}); 

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

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

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

//listen on port 8080 
webServer.listen(8080, function() { 
    console.log('listening on http://localhost:8080'); 
}); 

私のhtmlファイル "socket.io.jsは(見つかりません)https://domain.com/socket.io/?EIO=3&transport=polling&t=LPgZs2K 404をGET"。このhttps://domain.com/test.html

<!DOCTYPE html> 
<html> 
    <head> 
    <title>EasyRTC Demo:EasyRTC Demo: Video+Audio HD 720</title> 
    <link rel="stylesheet" type="text/css" href="/easyrtc/easyrtc.css" /> 
    <script src="js/socket.io.js"></script> 
    <script type="text/javascript" src="js/easyrtc.js"></script> 
    <script type="text/javascript" src="js/video.js"></script> 
<script> 
var selfEasyrtcid = ""; 


function connect() { 
    easyrtc.setVideoDims(1280,720); 
    easyrtc.enableDebug(false); 
    easyrtc.setRoomOccupantListener(convertListToButtons); 
    easyrtc.easyApp("easyrtc.videoChatHd", "selfVideo", ["callerVideo"], loginSuccess, loginFailure); 
} 


function clearConnectList() { 
    var otherClientDiv = document.getElementById("otherClients"); 
    while (otherClientDiv.hasChildNodes()) { 
    otherClientDiv.removeChild(otherClientDiv.lastChild); 
    } 
} 


function convertListToButtons (roomName, data, isPrimary) { 
    clearConnectList(); 
    var otherClientDiv = document.getElementById("otherClients"); 
    for(var easyrtcid in data) { 
    var button = document.createElement("button"); 
    button.onclick = function(easyrtcid) { 
     return function() { 
     performCall(easyrtcid); 
     }; 
    }(easyrtcid); 

    var label = document.createTextNode(easyrtc.idToName(easyrtcid)); 
    button.appendChild(label); 
    button.className = "callbutton"; 
    otherClientDiv.appendChild(button); 
    } 
} 


function performCall(otherEasyrtcid) { 
    easyrtc.hangupAll(); 
    var acceptedCB = function(accepted, caller) { 
    if(!accepted) { 
     easyrtc.showError("CALL-REJECTED", "Sorry, your call to " + easyrtc.idToName(caller) + " was rejected"); 
    } 
    }; 
    var successCB = function() {}; 
    var failureCB = function() {}; 
    easyrtc.call(otherEasyrtcid, successCB, failureCB, acceptedCB); 
} 


function loginSuccess(easyrtcid) { 
    selfEasyrtcid = easyrtcid; 
    document.getElementById("iam").innerHTML = "I am " + easyrtc.cleanId(easyrtcid); 
} 


function loginFailure(errorCode, message) { 
    easyrtc.showError(errorCode, message); 
} 


// Sets calls so they are automatically accepted (this is default behaviour) 
easyrtc.setAcceptChecker(function(caller, cb) { 
    cb(true); 
}); 
</script> 
    </head> 

    <body onload="connect();"> 
     <h1>EasyRTC Demo: Video+Audio HD 720p</h1> 
     <div id="demoContainer"> 
      <div> 
      Note: your own image will show up postage stamp sized, while the other party"s video will be shown in high-definition (1280x720). Note: not all webcams are seen by WebRTC as providing high-definition video; the fallback is to use standard definition (640x480). 
      </div> 
      <div id="connectControls"> 
      <div id="iam">Not yet connected...</div> 
      <br /> 
      <strong>Connected users:</strong> 
      <div id="otherClients"></div> 
      </div> 
      <div id="videos"> 

      <div style="position:relative;float:left;" width="1282" height="722"> 
       <video autoplay="autoplay" id="callerVideo"></video> 
       <video class="easyrtcMirror" autoplay="autoplay" id="selfVideo" muted="true" volume="0" ></video> 
      </div> 
      <!-- each caller video needs to be in it"s own div so it"s close button can be positioned correctly --> 
      </div> 
     </div> 
    </body> 
</html> 

Socket.io.jsのような構造:あなたはソケットを確立するところhttp://81.171.38.245/js/socket.io.js

+0

私は表示されませんサーバーがポート80を使用していないため、URL +ポートを含めてください。 例:var socket = io( "http://domain.com:8080"); – user2267175

+0

ありがとう、test.htmlファイルは、ちょうどウェブサーバーのポート80にあります。どこに "var socket = io(" domain.com:8080 ");"という部分を含めるべきですか? ive added socket.io.js(http://81.171.38.245/js/socket.io.js) – Vazzilly

+0

私はeasyrtcが何であるか、それが何をしているのか本当に分かりません。しかし、いくつかの質問.. easyrtcはソケットio経由でnode.jsサーバーに接続しますか?そうでない場合、node.jsサーバーにどこに接続していますか、そしてどこに情報を送信/受信しようとしていますか? – user2267175

答えて

0

は、の専門家を取得するが、これは私のために困難に少しあるようです