randunel / node-srcds-rcon

Node.JS high-level wrapper for SRCDS's remote console (RCON) https://developer.valvesoftware.com/wiki/RCON
107 stars 18 forks source link

Need a little bit of help #4

Closed pranaymk closed 8 years ago

pranaymk commented 10 years ago

I am currently working on a project and require the execution of commands on a remote tf2 server.

When I try to execute commands in the same way the example suggests, I don't have any command executed. But it seems to connect, well I don't get an error.

I am not quite sure what I am doing wrong. I am sure I have the correct password.

I would appreciate any help or guidance, here is my code.

var Rcon = require('srcds-rcon');

var rcon = new Rcon('iphidden', 'passwordhidden');

rcon.connect(function() {
    console.log('connected');
    rcon.kick('pmk010', function(err, res) {
        console.log('kicked player pmk010', res);
    });
});
randunel commented 10 years ago

Is there any output when you try to print err or res? Is there an error thrown when you call rcon.kick?

Try:

rcon.connect(function(err) {
    console.log('after connect', err);
    rcon.runCommand('kick pmk010', function(err, res) {
        console.log('after command', err, res);
    });
});

Unfortunately, I have never tested this with tf2, so I would appreciate some help debugging :) Make sure the rcon password is correct, though. At the moment, the timeout is not implemented, but should be really soon (next week) because I'm working on a project which needs it :D

pranaymk commented 10 years ago

With both my original code and your code nothing at all is printed to the console. All it shows in the directory of the file.

With your code nothing appears to happen either. I have tried multiple variations, putting "rcon kick pmk010" as that is how it is in the console, and trying to test other commands to no avail.

The password is correct as I have used it in the in-game console. I will try to play around a little see what I can do. If you have any further suggestions as to things I should try I would greatly appreciate it.

Many thanks,

pmk010

randunel commented 10 years ago

The only way I could reproduce what you are describing is by changing the rcon_password to something else. That's when I see the following srcds server console output rcon from "192.168.0.2:55190": Bad Password.

I am installing a tf2 server now to test, maybe something's different.

pranaymk commented 10 years ago

Okay, I don't suppose it could be related to the fact that the server I am trying to connect to is not local?

randunel commented 10 years ago

I was unable to test with tf2 because it apparently only works on 32 bit systems. I couldn't find a workaround for libtcmalloc_minimal.so.4: wrong ELF class: ELFCLASS64. Sorry about that.

I have tested the rcon with non-local servers, including with a different game, Rust. So I doubt it's a remote/local issue. Until I put my hands on a tf2 server, I cannot test this theory.

pranaymk commented 10 years ago

I will try to test it on a local tf2 server and leave my feedback.

randunel commented 10 years ago

I have added extra logging info in the latest version. Please grab the latest version 1.1.3 and set the DEBUG env var to true:

npm install srcds-rcon@1.1.3
DEBUG=true node .

After that, copy+paste the output here. It should be quite verbose.

Later edit: make sure you add the port when connecting...

pranaymk commented 10 years ago

Okay, I have done as you have said. Here is the output. Rcon password edited out for obvious reasons.

From what I can tell it seems to connect, but does not have any affect on the server, and does not display anything in the console, without DEBUG enabled.

Again thanks for your time and help with this!

Initialized rcon instance { connected: false,
  connecting: false,
  address: { host: '217.163.24.69', port: '27015' },
  password: 'edited-password',
  protocol: null,
  commands: {} }
Connecting { host: '217.163.24.69', port: '27015' } edited-password
Instantiated connection { host: '217.163.24.69', port: '27015' }
Initializing TCP connection to 217.163.24.69:27015
Sending rcon password edited-password
Sending packet 1
Sending TCP data <Buffer 14 00 00 00 01 00 00 00 03 00 00 00 62 32 39 36 34 33 4
3 33 31 51 00 00>
TCP connection established
Sent packet 1
Connected, initializing cvarlist
Sending packet 2
Sending TCP data <Buffer 12 00 00 00 02 00 00 00 02 00 00 00 63 73 31 33 63 34 3
3 34 00 00>
Sending packet 3
Sending TCP data <Buffer 0a 00 00 00 03 00 00 00 00 00 00 00 00 00>
Sent packet 2
Sent packet 3
randunel commented 10 years ago

I edited the buffer data in your post. Please change your server's rcon password, just to be sure, because the buffer can be decoded. I will look into this, thanks.

So far, I have a pretty good idea what's going on. The connection succeeds, but the cvarlist command never returns from the server, so tf2 might have a different implementation. I will find a way to remove it without affecting already-existing versions.

pranaymk commented 10 years ago

I didn't realise about the buffer thing so thank you for letting me know.

If there is anything I can do to help you please do let me know. And again thank you for your support with this.

randunel commented 10 years ago

Until I fix the cvarlist issue, you should be able to use the project. Instead of rcon.changelevel, use rcon.runCommand('changelevel mapname', cb). Just grab the latest version, npm install srcds-rcon@1.1.4. See https://github.com/randunel/node-srcds-rcon/blob/master/dev/auth.js for examples, when initializing the Rcon instance, pass the config object with initCvars: false.

pranaymk commented 10 years ago

Thank you very much! Tested it and it works as it should. I'll leave it down to you as to whether you want to close the issue, or wait until a fix for the cvarlist issue is released.

randunel commented 8 years ago

cvarlist removed in v2.