简体   繁体   中英

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

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.

Install Socket.io inside your repository:

npm install socket.io --save 

After, config the index.js(file from your tutorial):

   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:

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

Check if works with Console (Chrome/ Mozilla, etc).

In my example I use Chrome (Ctrl + shift + I):

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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