gpt4 book ai didi

node.js - Socket.io、https 和 Express 连续连接/断开循环

转载 作者:太空宇宙 更新时间:2023-11-04 01:11:25 24 4
gpt4 key购买 nike

我正在尝试在 Node 上同时使用 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

最佳答案

通过卸载 Node v0.10.9 并安装 v0.10.10 修复。

关于node.js - Socket.io、https 和 Express 连续连接/断开循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16982584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com