When starting the nodejs application, I also ran into the same issue you were talking about. Before my code looks like this.
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var mongoChat = require('./app/mongo_chat');
var ip = "127.0.0.1";
var port = 3000;
var users = {};
var WhisperChek = false;
var storage=[];
app.use(express.static(__dirname + '/public'));
app.get('/', function (req, res) {
res.sendfile('index.html');
});
io.on('connection', function (socket) {
mongoChat.mognolizer(io,socket, users, WhisperChek);
function updateNicknames() {
io.emit('nickname', Object.keys(users));
}
socket.on('disconnect', function (data) {
if (!socket.Username)return;
delete users[socket.Username];
updateNicknames();
});
});
http.listen(port,ip, function () {
console.log('listening on *:3000');
});
But I removed var ip="127.0.0.1"from the code and updated the listening function as:
http.listen(port, function () {
console.log('listening on *:3000');
});
localhost, .. localhost:3000, ipaddress, .. ipaddress:3000. , ip 127.0.0.1, localhost, ipaddress, , , . , , .