pushrax / node-rcon

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

Commands are not sending to the server console #40

Open Meow-Bots opened 2 years ago

Meow-Bots commented 2 years ago

This is my .js

var Rcon = require('/home/kibee/node_modules/rcon/node-rcon')

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

var UwU = new Rcon('ip', port, 'passwords', options);

UwU.on('auth', function() {
console.log("Authenticated <3");
}).on('response', function(str) {
console.log("Got response: " + str);
}).on('end', function() {
console.log("Socket closed!");
});

UwU.connect();

when i connect to the server it sent Authenticated <3, i also tried UwU.send("help"); and it works when the command is from the .js but when i sent the command from my rcon it just doesnt work. its rcon for minecraft btw.

pushrax commented 2 years ago

it works when the command is from the .js but when i sent the command from my rcon it just doesnt work.

I don't follow, can you clarify which cases are working and which are not?

One piece of standard advice is to make sure you're sending the command after the authentication callback happens, for example:

UwU.on('auth', function() {
  console.log("Authenticated <3");
  UwU.send("help");
}).on('response', function(str) {
  console.log("Got response: " + str);
}).on('end', function() {
  console.log("Socket closed!");
});
Meow-Bots commented 2 years ago

what I meant is, the commands only work when I put them in the js file like this is my js

var Rcon = require('/home/kibee/node_modules/rcon/node-rcon')

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

var UwU = new Rcon('ubuntu-ts.meowbot.moe', 32869, 'Lks1543562879@@', options);

UwU.on('auth', function() {
console.log("Authenticated <3");
console.log("Sending command: help")
UwU.send("/help");
}).on('response', function(str) {
console.log("Got response: " + str);
}).on('end', function() {
console.log("Socket closed!");
});

UwU.connect();

the /help command worked when i launch the js file but when i type /help, the command didnt send to the rcon server and nothing happened Untitled3

pushrax commented 2 years ago

This library doesn’t handle console input. Sending commands is left to the user. If you would like to send commands from console input, try out this example https://github.com/pushrax/node-rcon/blob/master/examples/stdio.js

Meow-Bots commented 2 years ago

I just tried the example, the most thing works fine but the backspace key doesn't work.

pushrax commented 2 years ago

Which terminal software are you using? This code is supposed to handle backspace, but the escape code it's using may not be compatible with all terminals. https://github.com/pushrax/node-rcon/blob/a683f11dd6160fc4fe8ef46139413f862dabb238/examples/stdio.js#L58-L60

Meow-Bots commented 2 years ago

I was using Tabby Terminal, now I just tried on Windows PowerShell and it doesn't work either. Same thing with the Windows command prompt. When I press backspace I got this: Untitled4