socket.io chat room is not working

207 views Asked by At

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.

1

There are 1 answers

0
Sayuri Mizuguchi On

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):

enter image description here