node-rcon icon indicating copy to clipboard operation
node-rcon copied to clipboard

Waiting for Auth event

Open ZariZaryab opened this issue 4 years ago • 5 comments
trafficstars

var options = {
  tcp: false,
udp: true,       // false for UDP, true for TCP (default true)
  challenge: false  // true to use the challenge protocol (default true)
};

var conn = new Rcon('13.127.42.200', 28961, 'rcon',options);

conn.on('auth', function() {
  // You must wait until this event is fired before sending any commands,
  // otherwise those commands will fail.
  console.log("Authenticated");
  console.log("Sending command: help")
  conn.send("help");
}).on('response', function(str) {
  console.log("Response: " + str);
}).on('error', function(err) {
  console.log("Error: " + err);
}).on('end', function() {
  console.log("Connection closed");
  process.exit();
});

conn.connect();
conn.send("map mp_powcamp")

This doesn't work for some reasons, what to do?

ZariZaryab avatar Sep 29 '21 02:09 ZariZaryab

See the comment in the example:

conn.on('auth', function() {
  // You must wait until this event is fired before sending any commands,
  // otherwise those commands will fail.

This is also explained at the end of the example file https://github.com/pushrax/node-rcon/blob/a683f11dd6160fc4fe8ef46139413f862dabb238/examples/basic.js#L22-L27

Try this code:

var options = {
  tcp: false,
  challenge: false
};

var conn = new Rcon('13.127.42.200', 28961, 'rcon', options);

conn.on('auth', function() {
  // You must wait until this event is fired before sending any commands,
  // otherwise those commands will fail.
  console.log("Authenticated");
  conn.send("map mp_powcamp");
}).on('response', function(str) {
  console.log("Response: " + str);
}).on('error', function(err) {
  console.log("Error: " + err);
}).on('end', function() {
  console.log("Connection closed");
  process.exit();
});

conn.connect();

pushrax avatar Sep 29 '21 04:09 pushrax

var options = {
  tcp: false,
  challenge: false
};

var conn = new Rcon('13.127.42.200', 28961, 'rcon', options);

conn.on('auth', function() {
  // You must wait until this event is fired before sending any commands,
  // otherwise those commands will fail.
  console.log("Authenticated");
  conn.send("map mp_powcamp");
}).on('response', function(str) {
  console.log("Response: " + str);
}).on('error', function(err) {
  console.log("Error: " + err);
}).on('end', function() {
  console.log("Connection closed");
  process.exit();
});

conn.connect();

I tried this code at the very first time and did so again but, it just shows console message "Authenticated" and nothing else appears in terminal. Moreover, this command is supposed to change the map but, server doesn't change map or nothing else is working.

ZariZaryab avatar Sep 29 '21 05:09 ZariZaryab

Okay, got it.

Can you provide any more information? What game server are you using?

If possible, a packet capture would be helpful to identify any issue. For example, using wireshark or tcpdump.

pushrax avatar Sep 29 '21 05:09 pushrax

I'm using Call of Duty 1 server for this, the server is hosted on linux, with mods.

ZariZaryab avatar Sep 29 '21 05:09 ZariZaryab

var options = {
  tcp: false,
  challenge: false
};

var conn = new Rcon('13.127.42.200', 28961, 'rcon', options);

conn.on('auth', function() {
  // You must wait until this event is fired before sending any commands,
  // otherwise those commands will fail.
  console.log("Authenticated");
  conn.send("map mp_powcamp");
}).on('response', function(str) {
  console.log("Response: " + str);
}).on('error', function(err) {
  console.log("Error: " + err);
}).on('end', function() {
  console.log("Connection closed");
  process.exit();
});

conn.connect();

I tried this code at the very first time and did so again but, it just shows console message "Authenticated" and nothing else appears in terminal. Moreover, this command is supposed to change the map but, server doesn't change map or nothing else is working.

same problem , with wrong password , auth is true 😂 wtf ?

Thomas-is-dev avatar Jul 21 '23 11:07 Thomas-is-dev