vue.js / socket.io:JavaScript控制台中出现404错误

时间:2019-04-17 10:31:04

标签: javascript vue.js socket.io

我的应用程序的前端部分正在发出如下请求:

GET http://lizardgizzards.com:4001/?EIO=3&transport=polling&t=Megqhnd 404 (Not Found)
h.create @ vue-socketio.js?5132:8
h @ vue-socketio.js?5132:8
u.request @ vue-socketio.js?5132:8
u.doPoll @ vue-socketio.js?5132:8
h.poll @ vue-socketio.js?5132:8
h.doOpen @ vue-socketio.js?5132:8
i.open @ vue-socketio.js?5132:8
h.open @ vue-socketio.js?5132:8
h @ vue-socketio.js?5132:8
h @ vue-socketio.js?5132:8
l.open.l.connect @ vue-socketio.js?5132:8
l @ vue-socketio.js?5132:8
l @ vue-socketio.js?5132:8
c @ vue-socketio.js?5132:8
value @ vue-socketio.js?5132:10
t @ vue-socketio.js?5132:10
(anonymous) @ main.js?56d7:6
./src/main.js @ app.js:2059
__webpack_require__ @ app.js:724
fn @ app.js:101
1 @ app.js:2085
__webpack_require__ @ app.js:724
(anonymous) @ app.js:791
(anonymous) @ app.js:794

我正在后端运行Express。

Express日志输出(不久前输出显示200s,而不是404s):

GET /?EIO=3&transport=polling&t=Megrimu 404 0.962 ms - 2200
GET /?EIO=3&transport=polling&t=MegrkOq 404 0.990 ms - 2200
GET /?EIO=3&transport=polling&t=Megrm6D 404 0.979 ms - 2200
GET /?EIO=3&transport=polling&t=Megrnpa 404 0.931 ms - 2200
GET /?EIO=3&transport=polling&t=MegrpWz 404 1.691 ms - 2200
GET /?EIO=3&transport=polling&t=MegrrEK 404 0.990 ms - 2200
GET /?EIO=3&transport=polling&t=Megrsxi 404 0.961 ms - 2200
GET /?EIO=3&transport=polling&t=Megruf6 404 0.933 ms - 2200

我在后端添加了一个基本的socket.io代码块,以便希望通过socket.io连接。下面的代码我只是作为占位符添加了。

io.on('connection', function (socket) {
    socket.emit('news', { hello: 'world' });
    socket.on('my other event', function (data) {
        console.log(data);
    });
});

0 个答案:

没有答案