Registry / http-networking / rcon-client

rcon-client

JSON →
library4.2.5jsnpmunverified

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.

npm install rcon-client
INSTALL
IMPORT
SIG · RCON-CLIENT
R
rcon-client
http-networkingjavascriptv4.2.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Rcon
import { Rcon } from 'rcon-client'
const Rcon = require('rcon-client')
The library primarily targets modern JavaScript environments and TypeScript, preferring ES module syntax. While CommonJS might work via transpilation or older Node versions, direct `require` is not the idiomatic usage.
Rcon.connect
const rcon = await Rcon.connect({ host: 'localhost', port: 25575, password: '1234' })
const rcon = Rcon.connect({ host: 'localhost', port: 25575, password: '1234' })
The `connect` static method is asynchronous and returns a Promise, so it must be awaited to get the `Rcon` instance. Forgetting `await` will result in a Promise object instead of the connected Rcon client.
RconEvents
import type { RconEvents } from 'rcon-client'
To type-hint event handlers for the `Rcon` instance's event emitter, import `RconEvents` as a type. This is useful for implementing custom event listeners with strong typing.

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();
Debug
Known issues
deprecatedThe `rcon-client` library is no longer actively maintained. The maintainer explicitly states this in the README, advising caution or considering alternative implementations. This means bug fixes, security updates, and new features are unlikely to be released.
fix
For new projects, evaluate more actively maintained RCON client libraries. If already using, be aware of potential unaddressed issues and consider contributing to the project or forking it if critical updates are needed.
affects: >=4.0.0
gotchaImproper handling of connection state: The `Rcon` instance supports connecting and disconnecting at any time. However, attempting to send commands on a disconnected Rcon instance will result in errors. Always ensure the client is connected before sending commands.
fix
Use the `connect()` method before `send()`, and consider implementing an auto-reconnect logic using the exposed events (`connect`, `end`, `error`) if your application requires resilient connections. The `connect` method can be called multiple times on the same instance after calling `end`.
affects: >=1.0.0
gotchaForgotten `await` for asynchronous operations. All network operations (`Rcon.connect`, `rcon.send`) return Promises and must be awaited to correctly handle their results and prevent unhandled promise rejections.
fix
Always use `await` before `Rcon.connect(...)` and `rcon.send(...)`. Wrap asynchronous calls in a `try...catch` block to gracefully handle potential connection or command execution errors.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'send')
Attempting to call `send()` on an `Rcon` instance that has not yet successfully connected, or after it has been explicitly `end()`ed, or if `await Rcon.connect()` was forgotten.
fix
Ensure `await rcon.connect()` completes successfully before calling `rcon.send()`. If using the static `Rcon.connect()`, ensure you `await` its result. Check connection status via events (`connect`, `end`, `error`) if managing connection state manually.
Error: RCON connection failed: Authentication failed.
The provided password for the RCON server is incorrect.
fix
Verify the RCON password configured on your Minecraft server and ensure it matches the `password` field in your `Rcon.connect()` options. Double-check for typos or leading/trailing spaces.
Error: connect ECONNREFUSED
The RCON client was unable to establish a TCP connection to the specified host and port. This usually means the server is not running, RCON is not enabled, or a firewall is blocking the connection.
fix
1. Ensure your Minecraft server is running. 2. Verify that RCON is enabled in your server's `server.properties` (`enable-rcon=true`). 3. Check the `rcon.port` and `rcon.password` in `server.properties`. 4. Confirm no firewall (OS or network) is blocking connections to the RCON port on the server host. 5. Double-check the `host` and `port` values in your `Rcon.connect()` call.
Upgrade
Version history
4.2.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
rcon-client — npm install rcon-client · libregistry