我正在尝试在节点上同时使用 socket.io、express 和 https。当 socket.io 连接时,它会立即断开连接,再次重新连接并循环。可以使用以下代码重新创建问题...
服务器
var app = express();
var server = https.createServer(sslOptions, app)
var io = require('socket.io').listen(server);
app.use(express.static('./public'));
server.listen(port, function(){});
客户
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('https://testdomain.com', { secure: true });
</script>
错误
debug - client authorized
info - handshake authorized uBDQXqTmgbJzm-lnSWsm
debug - setting request GET /socket.io/1/websocket/uBDQXqTmgbJzm-lnSWsm
debug - set heartbeat interval for client uBDQXqTmgbJzm-lnSWsm
debug - client authorized for
debug - websocket writing 1::
warn - websocket parser error: reserved fields must be empty
info - transport end (undefined)
debug - set close timeout for client uBDQXqTmgbJzm-lnSWsm
debug - cleared close timeout for client uBDQXqTmgbJzm-lnSWsm
debug - cleared heartbeat interval for client uBDQXqTmgbJzm-lnSWsm
debug - discarding transport