简体   繁体   English

socket.io 聊天室不工作

[英]socket.io chat room is not working

I am following the tutorial given at the url: https://codelabs.developers.google.com/codelabs/webrtc-web/#6我正在按照网址提供的教程进行操作: https : //codelabs.developers.google.com/codelabs/webrtc-web/#6

When I run the server and open index.html on browser then it gives me error http://localhost:8080/socket.io/?EIO=3&transport=polling&t=1486104971951-58 (not found) I have done everything which I could but I can't get rid of this error.当我运行服务器并在浏览器上打开 index.html 时,它给了我错误http://localhost:8080/socket.io/?EIO=3&transport=polling&t=1486104971951-58 (未找到)我已经做了我能做的一切但我无法摆脱这个错误。

Install Socket.io inside your repository:在您的存储库中安装 Socket.io:

npm install socket.io --save 

After, config the index.js(file from your tutorial):之后,配置 index.js(教程中的文件):

   var express = require('express')
   var app     = express();
   var server  = require('http').createServer(app);
   var io      = require('socket.io').listen(server);

   server.listen(app.get('80')); 

And inside your archive HTML/EJS or another you want, add:在你的存档 HTML/EJS 或其他你想要的文件中,添加:

<script src="/socket.io/socket.io.js"></script>

Check if works with Console (Chrome/ Mozilla, etc).检查是否适用于控制台(Chrome/Mozilla 等)。

In my example I use Chrome (Ctrl + shift + I):在我的示例中,我使用 Chrome (Ctrl + shift + I):

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM