This question is an exact duplicate:

I try to run the chat from the example on the SOCKET.IO website.

server.js:

var express = require('express'); var app = express(); var server = app.listen(3000); var io = require('socket.io')(server); io.on('connection', function(socket){ socket.emit('an event sent to all connected clients'); console.log('a user connected'); socket.on('disconnect', function(){ console.log('user disconnected'); }); socket.on('chat message', function(msg){ io.emit('chat message', msg); console.log('message: ' + msg); }); }); 

I launch: node server.js &

 netstat -lnp -t tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 9429/node 

As far as I understand, everything is fine, port 3000 is listening.

I try from the browser: mydomen.com:3000 - does not load .

on host - Service: Virtual server / OpenVZ

Where is that so? Believe me - I shoveled dozens of scripts, I killed 2 days, I don’t understand what's the matter - everyone works, I don’t.

Reported as a duplicate by Dmitriy Simushev , aleksandr barakin , zRrr , Streletz , VenZell 23 May '16 at 11:40 .

This question has been marked as a duplicate of an existing one.

  • Naturally, in the same place in the code does not appear anywhere "to give a page with a chat." Do you understand what is written in your code? Not? And it is worth reading. - D-side
  • Yes, I just do not understand much! took an example from habrahabr.ru/post/127525 Pts loaded for a long time, messages are not sent - cancer
  • one
    Because instead of blindly copying examples, they should be disassembled :) - D-side
  • Pretty instructive. thanks - cancer

1 answer 1

Keep the collected example (all from the off site socket.io) Download