我正在尝试在php文件上运行nodejs。

<script src="htps://xxx.com:8445/socket.io/socket.io.js"></script>
<script src="htps://xxx.com:8445/easyrtc/easyrtc.js" type="text/javascript"></script>

Server.js:
// 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 easyrtc = require("../");   // EasyRTC external 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 + ":8445"));

// Start Express https server on port 8445
var webServer = https.createServer(
{
    key:  fs.readFileSync("/etc/apache2/ssl/xxx.com.key"),
    cert: fs.readFileSync("/etc/apache2/ssl/xxx.com.crt")
},
httpApp).listen(8445);

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

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

错误 :
php - easyRTC连接到socket.io服务器时出错-LMLPHP

Node.js可以工作,但是我遇到了这样的错误。如果我不使用PHP,它可以工作。

最佳答案

对于来自谷歌的任何人,easyRTC都假定http服务器和ws服务器位于相同的url/端口上。要解决此问题,需要在包含easyRTC之后运行easyrtc.setSocketUrl("https://thedomain.com.tr:8445");方法

10-05 20:28