0
var app = require('http').createServer(handler);
var Rcon = require('rcon');
var url  = require('url');

app.listen(7777);
console.log('Server started.');
function handler (req, res) {
    console.log('New connection!');
    res.writeHead(200);
    var urlParts = url.parse(req.url, true);
    var server = urlParts.query;
    var conn = new Rcon(server.ip, server.port, server.password);
    conn.on('auth', function() {
        conn.send(server.command);
        console.log('Sent command!');
    }).on('response', function(data) {
        res.end(data);
        console.log('Response: '+data);
    }).on('error', function(data) {
        res.end('error');
        console.log('Error: '+data);
    }).on('err', function(data) {
        res.end('error');
        console.log('Error: '+data);
    });
    conn.connect();
}

All of that works perfectly on localhost but when I upload to a remote server and run it, it responds with error in browser and with this in the console:

Server started. New connection! Error: TypeError: Object 0�P�q has no
method 'writeInt32LE' New connection! Error: Error: EINVAL, Invalid
argument
3
  • 1
    might be an older node.js version on remote server.. the script probably needs newer. though the script looks so dead simple .. Commented Nov 6, 2013 at 21:23
  • what is your node version? Commented Nov 7, 2013 at 1:12
  • Ah how would I uninstall node so I can reinstall it? Commented Nov 7, 2013 at 7:37

1 Answer 1

2

First guess: rcon module contains compiled extensions and you checked the files of node_modules/rcon into git and then tried to run them on a different CPU architecture. You need to run npm rebuild on the remote server for a quick fix and to get your node_modules folder out of your git repository as the correct long-term fix.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.