Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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 server socket.io-client与SSL_Node.js_Ssl_Https_Socket.io - Fatal编程技术网

node.js server socket.io-client与SSL

node.js server socket.io-client与SSL,node.js,ssl,https,socket.io,Node.js,Ssl,Https,Socket.io,我尝试设置两个node.js服务器通过socket.io相互通信。节点服务器使用SSL,但我没有让它运行。我没有得到任何反馈,与此接近: 这是行不通的。没有回应 var clientio = require('socket.io-client'); console.log('Trying stuff ...'); // the channel does not exist var socket = clientio.connect( 'http://localhost:4000/news'

我尝试设置两个node.js服务器通过socket.io相互通信。节点服务器使用SSL,但我没有让它运行。我没有得到任何反馈,与此接近:

这是行不通的。没有回应

var clientio = require('socket.io-client');
console.log('Trying stuff ...');

// the channel does not exist
var socket = clientio.connect( 'http://localhost:4000/news' );

// I expect this event to be triggered
socket.on('connect_failed', function(){
    console.log('Connection Failed');
});
socket.on('connect', function(){
    console.log('Connected');
});
socket.on('disconnect', function () {
  console.log('Disconnected');
});
但如果我尝试:

// Bind to the news namespace, also get the underlying socket
var ns_news = clientio.connect( 'https://localhost:9000' );
var socket = ns_news.socket

// Global events are bound against socket
socket.on('connect_failed', function(){
    console.log('Connection Failed');
});
socket.on('connect', function(){
    console.log('Connected');
});
socket.on('disconnect', function () {
  console.log('Disconnected');
});

// Your events are bound against your namespace(s)
ns_news.on('myevent', function() {
    // Custom event code here
});
我可以看到ns_news没有元素套接字,所以我得到:

TypeError: Cannot call method 'on' of undefined
那么,如果连接成功与否,我如何通过反馈连接这两台服务器? 我的以下问题是:

这两台服务器如何相互验证? 意思是:服务器A对服务器B说: -嘿,把那根秘密绳子给我 服务器B检查服务器A的证书是否正常 -这是绳子

如何使用node执行此操作