Minecraft RCON Client

4.2.5 · abandoned · verified Tue Apr 21

rcon-client is a JavaScript/TypeScript library designed to connect to and interact with Minecraft servers via the RCON protocol. Its key differentiator is a built-in packet queue that limits pending requests, which is particularly useful for sending multiple commands concurrently without overwhelming the server. The library supports persistent connections, allowing an Rcon instance to connect and disconnect multiple times. It leverages async/await patterns for network operations and ships with TypeScript types, making it suitable for modern JavaScript and TypeScript projects. The current stable version is 4.2.5. However, it's explicitly stated by the maintainer that the library has not been actively maintained for a while, implying an infrequent release cadence and potential for unaddressed issues. Developers should consider this lack of maintenance when choosing this library for new projects. It uses Node.js's EventEmitter internally for connection lifecycle events.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to establish an RCON connection using the static `connect` method, send a single command, execute multiple commands concurrently using `Promise.all`, and properly close the connection. It includes basic error handling and uses environment variables for sensitive connection details.

import { Rcon } from "rcon-client";

async function runRconCommands() {
    console.log('Attempting to connect to RCON server...');
    try {
        const rcon = await Rcon.connect({
            host: process.env.RCON_HOST ?? 'localhost',
            port: parseInt(process.env.RCON_PORT ?? '25575'),
            password: process.env.RCON_PASSWORD ?? '1234'
        });
        console.log('Connected to RCON server.');

        console.log('Sending \"list\" command...');
        const listResponse = await rcon.send("list");
        console.log('Response from \"list\":', listResponse);

        console.log('Sending \"help\" and \"whitelist list\" concurrently...');
        let responses = await Promise.all([
            rcon.send("help"),
            rcon.send("whitelist list")
        ]);

        console.log('Responses from concurrent commands:');
        for (const response of responses) {
            console.log(response);
        }

        rcon.end();
        console.log('RCON connection ended.');
    } catch (error) {
        console.error('Failed to connect or send RCON command:', error);
    }
}

runRconCommands();

view raw JSON →