在没有ssl连接的情况下,一切正常。
我在设置之后得到的回复:
socket.io-1.4.5.js:1
GET https://domain.com:3000/socket.io/?EIO=3&transport=polling&t=LILwU3l net::ERR_INSECURE_RESPONSE
node.js v.6.1
{
//...,
"dependencies":
{
"socket.io": "1.4.5"
}
}
查看如果仅声明端口,socket.io如何解决创建服务器的问题:https://github.com/socketio/socket.io/blob/master/lib/index.js#L212
const
fs = require('fs'),
https = require('https').createServer(
{
// certificate by godaddy (G2)
key : fs.readFileSync('/etc/ssl/private/domain.key'),
cert: fs.readFileSync('/etc/ssl/certs/domain.crt')
},
(req, res) =>
{
res.writeHead(404);
res.end();
}).listen(3000),
io = require('socket.io')(https);
io.on('connection', (socket) => {console.log('CONNECTED');});
require.config(
{
shim:
{
'socketio':
{
exports: 'io'
}
},
paths:
{
socketio: 'https://cdn.socket.io/socket.io-1.4.5'
}
});
define(['socketio'], function(io)
{
var socket = io.connect('https://domain.com:3000');
});
$ openssl s_client -CApath /etc/ssl/certs/ -connect domain.com:3000 -showcerts
...
Verify return code: 0 (ok)