C
C
cancera2016-05-18 09:31:45
Node.js
cancera, 2016-05-18 09:31:45

How to run a chat (node.js, socket.io) on a website?

I'm trying to start the chat from the example on the socket.io site.
server.js:
var express = require('express');
var app = express();
varserver = 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 run:
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
is not loaded.
on the host - Service: Virtual server / OpenVZ
Where is it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cancera, 2016-05-19
@cancera

Decided!
the problem was on the server - registered port in a fusee.

C
catHD, 2016-05-18
@catHD

What do you expect to get there? You are making a chat from an example socket.io, why not use everything as written there?
https://github.com/socketio/socket.io/blob/master/...
Since you don't know what you're doing yet.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question