【发布时间】:2014-08-10 12:40:37
【问题描述】:
我正在尝试跟随位于http://socket.io/get-started/chat/ 的 Socket.IO 的简单示例。到目前为止,我的 index.js 文件中有以下代码:
// INDEX.JS 文件 var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function (req, res) { res.sendfile('index.html'); }); io.on('connection', function (socket) { socket.on('聊天消息', function (msg) { console.log('消息:' + msg); }); }); http.listen(3000, function () { console.log('正在监听 *:3000'); });我得到的错误是:
到 ws://localhost:3000/socket.io/?EIO=2&transport=websocket&sid=i0SyiRvHJC1GUiafAAAC 的连接在页面加载时中断。
我正在使用FireFox 浏览页面。它也不适用于Chrome。
【问题讨论】:
-
这和这个问题很相似 [socket.io 404 not found] (stackoverflow.com/questions/48198835/socket-io-404-error/…)