Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 无法使用SSL连接到套接字IO_Node.js_Socket.io - Fatal编程技术网

Node.js 无法使用SSL连接到套接字IO

Node.js 无法使用SSL连接到套接字IO,node.js,socket.io,Node.js,Socket.io,服务器: 客户: // Load libraries var https = require('https'); var fs = require('fs'); var socketio = require('socket.io'); // The server options var srvAddress = '123.123.123.123'; var srvPort = 8888; var srvOptions = { key: fs.readFileSync('ssl/cert

服务器:

客户:

// Load libraries
var https = require('https');
var fs = require('fs');
var socketio = require('socket.io');

// The server options
var srvAddress = '123.123.123.123';
var srvPort = 8888;
var srvOptions = {
    key: fs.readFileSync('ssl/cert.key'),
    cert: fs.readFileSync('ssl/cert.crt'),
    ca: fs.readFileSync('ssl/cert-ca.crt')
};

// Create a Basic server and response
var app = https.createServer(srvOptions, function(req, res) {
    res.writeHead(200);
    res.end('Online...');
});

// Create the Socket.io Server over the HTTPS Server
var io = socketio.listen(app, srvAddress);

// Now listen in the specified Port
app.listen(srvPort, srvAddress);
但客户端不连接到服务器。我尝试了http而不是https,但结果相同。
服务器工作正常。没有ssl证书连接就可以工作。当尝试通过web打开时,所有功能都可以正常工作。

如果今天出现相同的问题,这可能会有所帮助。不是相同的问题,我无法从socket.io-client连接,但例如,用于iOS的SocketIO客户端连接到服务器
var socket = require("socket.io-client").connect('https://123.123.123.123:8888', {secure: true});