我已经设置并可以成功地将我的套接字用于 iPhone 上使用端口 :3000 的聊天应用程序。但是,当我尝试使用端口 :443 时,我无法连接。
我的 index.js 文件开始于:
var app = require('express')();
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('...path/example.com.key'),
cert: fs.readFileSync('...path/example.com.crt'),
ca: fs.readFileSync('...path/intermediate.crt')
};
var server = https.createServer(options, app);
var io = require('socket.io')(server);
server.listen(443, function(){
console.log('Listening on *:443');
});
在客户端,我尝试的连接是:
var socket: SocketIOClient = SocketIOClient(socketURL: URL(string: "https://www.example.com:443")!)
套接字连接挂起并返回空 JSON。想知道我是否需要配置文件或其他东西来完成这项工作。如果我将上面的 443 更改为 3000,一切正常,但我需要使用 SSL。
最佳答案
SSL 与端口 443 无关。这意味着您可以使用任何其他未使用的端口并启用 SSL。请参阅:https://superuser.com/questions/791218/can-i-use-another-port-other-than-443-for-ssl-communication
关于ios - 将 SSL https 与 socket.io 和 swift 一起用于 iOS 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46874670/