A
A
ARX22019-04-17 11:28:19
Node.js
ARX2, 2019-04-17 11:28:19

How to install Socket.io on hosting?

Good afternoon.
I'm trying to install socket.io on the hosting, but it gives the following
server.js error:

var io = require('socket.io')(6001);
io.on('connection', function(socket){
  socket.on('channelfxer', function(mychanel){
    socket.join(mychanel);
  });
  socket.on('message', function(data){
    socket.broadcast.emit('message',data);
  });

  socket.on('readed', function(data){
    socket.to(data.room).emit('readed',data);
  });

socket.on('disconnect', function(){ });
});

error when I run:
events.js:182
      throw er; // Unhandled 'error' event
      ^
Error: listen EPERM :::6001
    at Object.exports._errnoException (util.js:1016:11)
    at exports._exceptionWithHostPort (util.js:1039:20)
    at Server.setupListenHandle [as _listen2] (net.js:1307:14)
    at listenInCluster (net.js:1355:12)
    at Server.listen (net.js:1455:7)
    at Server.listen.Server.attach (/home/k/kronosjy/node_modules/socket.io/lib/index.js:273:9)
    at new Server (/home/k/kronosjy/node_modules/socket.io/lib/index.js:59:17)
    at Server (/home/k/kronosjy/node_modules/socket.io/lib/index.js:44:41)
    at Object.<anonymous> (/home/k/kronosjy/.local/ws.server/server.js:1:92)
    at Module._compile (module.js:569:30)

I realized that the reason is in the port, even when I remove the port in server.js. Everything starts without errors, just does not reach the connection.
How can I connect this?
Maybe it's somehow possible to connect from the locale?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mertico, 2019-04-17
@Mertico

Most likely the port is occupied by someone, look
netstat -tulpn | grep --color :6001

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question