我遇到一个奇怪的问题,而socket.io在HTTP上运行正常,它在HTTPS上发出 404 错误,即使包括:
<script src="/socket.io/socket.io.js" />
以下是我的快速设置:
HTTP
var server = app.listen(app.get('port'), function() {
console.log("Express server listening on port " + app.get('port'));
});
io = socketio.listen(server);
HTTPS
var httpsServer = https.createServer({
key: privateKey,
cert: certificate,
ca: [c1, c2, c3],
requestCert: true,
rejectUnauthorized: false
}, app);
io = socketio.listen(server);
httpsServer.listen(app.get('port'), function() {
console.log("Express server listening on port " + app.get('port'));
});
除了socket.io,一切都在HTTPS上正常工作。