When you start, it gives an entry on the screen and this is how it hangs. I tried to change the port, I tried to fix something in the code, but it started when I moved the site to another server and the domain was also redirected to another ip. Server code is published below.

enter image description here

var PORT = 8008; var options = { // 'log level': 0 }; var mysql = require('mysql'); var connection = mysql.createConnection({ host : '****', user : '****', password : '****', database : '****' }); connection.connect(); var express = require('express'); var app = express(); var http = require('http'); var server = http.createServer(app); var io = require('socket.io').listen(server, options); server.listen(PORT); app.use('/static', express.static(__dirname + '/static')); app.get('/', function (req, res) { res.sendfile(__dirname + '/index.html'); }); io.sockets.on('connection', function (client) { client.on('message', function (message,id_my,id_you,id_you_book,komy) { try { client.emit('message'+message.id_you, message); client.broadcast.emit('message'+message.id_you, message); var post = {my_id: message.id_my, you_id: message.id_you_book, text: message.text, book: message.id_you, komy: message.komy, type: 5, date: new Date()}; var query = connection.query('INSERT INTO comment SET ?', post, function(err, result) { console.log('Π”ΠΎΠ±Π°Π²Π»Π΅Π½ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ ΠΊ ΠΊΠ½ΠΈΠ³Π΅'); }); } catch (e) { console.log(e); client.disconnect(); connection.end(); } }); client.on('stena', function (stena,id_my,id_you) { try { client.emit('stena'+stena.id_you, stena); client.broadcast.emit('stena'+stena.id_you, stena); var post = {users2: stena.id_my, text: stena.text, users: stena.id_you, type: 3, date: new Date()}; var query = connection.query('INSERT INTO repost SET ?', post, function(err, result) { console.log('Π”ΠΎΠ±Π°Π²Π»Π΅Π½Π° запись Π½Π° стСну'); }); } catch (e) { console.log(e); client.disconnect(); connection.end(); } }); client.on('comment', function (comment,id_my,id_you,id_you_post,komy) { try { client.emit('comment'+comment.id_you, comment); client.broadcast.emit('comment'+comment.id_you, comment); var post = {my_id: comment.id_my, you_id: comment.id_you_post, text: comment.text, post: comment.id_you, komy: comment.komy, type: 4, date: new Date()}; var query = connection.query('INSERT INTO comment SET ?', post, function(err, result) { console.log('Π”ΠΎΠ±Π°Π²Π»Π΅Π½ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ ΠΊ записС'); }); } catch (e) { console.log(e); client.disconnect(); connection.end(); } }); client.on('art', function (art,id_my,id_you,id_you_art,komy) { try { client.emit('art'+art.id_you, art); client.broadcast.emit('art'+art.id_you, art); var post = {my_id: art.id_my, you_id: art.id_you_art, text: art.text, art: art.id_you, komy: art.komy, type: 6, date: new Date()}; var query = connection.query('INSERT INTO comment SET ?', post, function(err, result) { console.log('Π”ΠΎΠ±Π°Π²Π»Π΅Π½ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ ΠΊ Π°Ρ€Ρ‚Ρƒ'); }); } catch (e) { console.log(e); client.disconnect(); connection.end(); } }); client.on('chat', function (chat) { try { client.emit(chat.id, chat); client.broadcast.emit(chat.id, chat); var post = {dialog: chat.id, text: chat.text, users: chat.my, status: 1, date: new Date()}; var query = connection.query('INSERT INTO chat SET ?', post, function(err, result) { console.log('Π”ΠΎΠ±Π°Π²Π»Π΅Π½ΠΎ сообщСниС'); }); } catch (e) { console.log(e); client.disconnect(); connection.end(); } }); }); 
  • I use digitalocean, there were no problems with launching something on vds, especially nodes. If it stops connecting to vds, you should read the logs of the vds itself. - Vasily Barbashev
  • @ Vasily Barbashev Yes, I also wanted to go there first. But I heard that there is traffic. I read it in Google, for any reason it is because of the port, can you tell me how to open it on VDS-e? - Albert Ushakov
  • And what is vds if not a secret? - Vladimir Gamalyan
  • @VladimirGamalian dedicated private server) - Vasily Barbashev
  • @ Vasily Barbashev you are just talking about him here, as if it was some particular provider. - Vladimir Gamalyan

1 answer 1

Error on the second screenshot - the port is already in use. NodeJS and firewall nothing to do with. Make sure that starting your own script does not keep it open earlier (by rebooting the VDS or by looking at the processes ps aux/kill -9 {id_Π½Π΅ΡƒΠ³ΠΎΠ΄Π½ΠΎΠ³ΠΎ} )

You can open the port from the outside, for example:

 iptables -A OUTPUT -p tcp --dport 8008 -j ACCEPT iptables -A INPUT -p tcp --dport 8008 -j ACCEPT 

The netstat -pan | grep 8008 netstat -pan | grep 8008 sure that it is open. Should be: tcp 0 0 0.0.0.0:8008 if you see 127.0.0.1:8008 then indicate in your script the ip on which it should open explicitly: 0.0.0.0

  • I would just write about rebooting VDS, which is an undesirable operation - etki
  • @Etki unwanted VDS reboot operation? And what is the reason? - Vasily Barbashev
  • @ Vasily Barbashev extra time and risks - etki
  • one
    @MaxZS servers never turn off. I came across a virtual machine that could not get to the ssh download due to the beaten system files. If you have never saved a service in a critical situation, then when you have to, do not restart the server. - etki
  • one
    @MaxZS my advice is not to do unnecessary operations where they are not needed, all the more radical. - etki