[英]Socket.IO Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR
I am having this issue with socket.io.我遇到了 socket.io 的问题。 In my repository I have the same content installed, and it has been working fine for days.
在我的存储库中,我安装了相同的内容,并且已经运行了好几天。 For an unknown reason, I can't get it to work again.
由于未知原因,我无法让它再次工作。 I have reinstalled and recreated all content, even start step-by-step all the process, but not possible to get it working.
我已重新安装并重新创建了所有内容,甚至逐步开始了所有过程,但无法使其正常工作。
Any help is appreciated - it really drives me to depression.感谢任何帮助 - 它真的让我陷入抑郁。
use strict';
const express = require('express');
const socketIO = require('socket.io');
const PORT = process.env.PORT || 3000;
const INDEX = '/public/index.html';
const server = express()
.use((req, res) => res.sendFile(INDEX, { root: __dirname }))
.listen(PORT, () => console.log(`Listening on ${PORT}`));
const io = socketIO(server);
io.emit('ServerToClient', 100);
io.on('connection', (socket) => {
console.log('Client connected');
socket.on('disconnect', () => console.log('Client disconnected'));
});
Client:客户:
let socket = io('http://localhost:3000');
socket.on('ServerToClient', (data) => {
console.log(data);
});
You have a syntax error in use strict';
您在
use strict';
. . You should change it to
'use strict';
您应该将其更改为
'use strict';
You should not be able to run the server.您应该无法运行服务器。
I use this link to view a simple example: Get started |我使用这个链接来查看一个简单的例子: Get started | Socket.IO
插座.IO
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.