pushrax / node-rcon

A generic RCON protocol client for node.js
MIT License
133 stars 31 forks source link

Waiting for Auth event #38

Open ZariZaryab opened 2 years ago

ZariZaryab commented 2 years ago
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?

pushrax commented 2 years ago

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();
ZariZaryab commented 2 years ago
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.

pushrax commented 2 years ago

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.

ZariZaryab commented 2 years ago

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

Thomas-R-dev commented 1 year ago
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 ?