{"id":15780,"library":"rcon-client","title":"Minecraft RCON Client","description":"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.","status":"abandoned","version":"4.2.5","language":"javascript","source_language":"en","source_url":"https://github.com/janispritzkau/rcon-client","tags":["javascript","rcon","client","promise","typescript","minecraft","protocol"],"install":[{"cmd":"npm install rcon-client","lang":"bash","label":"npm"},{"cmd":"yarn add rcon-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add rcon-client","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const Rcon = require('rcon-client')","symbol":"Rcon","correct":"import { Rcon } from 'rcon-client'"},{"note":"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.","wrong":"const rcon = Rcon.connect({ host: 'localhost', port: 25575, password: '1234' })","symbol":"Rcon.connect","correct":"const rcon = await Rcon.connect({ host: 'localhost', port: 25575, password: '1234' })"},{"note":"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.","symbol":"RconEvents","correct":"import type { RconEvents } from 'rcon-client'"}],"quickstart":{"code":"import { Rcon } from \"rcon-client\";\n\nasync function runRconCommands() {\n    console.log('Attempting to connect to RCON server...');\n    try {\n        const rcon = await Rcon.connect({\n            host: process.env.RCON_HOST ?? 'localhost',\n            port: parseInt(process.env.RCON_PORT ?? '25575'),\n            password: process.env.RCON_PASSWORD ?? '1234'\n        });\n        console.log('Connected to RCON server.');\n\n        console.log('Sending \\\"list\\\" command...');\n        const listResponse = await rcon.send(\"list\");\n        console.log('Response from \\\"list\\\":', listResponse);\n\n        console.log('Sending \\\"help\\\" and \\\"whitelist list\\\" concurrently...');\n        let responses = await Promise.all([\n            rcon.send(\"help\"),\n            rcon.send(\"whitelist list\")\n        ]);\n\n        console.log('Responses from concurrent commands:');\n        for (const response of responses) {\n            console.log(response);\n        }\n\n        rcon.end();\n        console.log('RCON connection ended.');\n    } catch (error) {\n        console.error('Failed to connect or send RCON command:', error);\n    }\n}\n\nrunRconCommands();","lang":"typescript","description":"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."},"warnings":[{"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.","message":"The `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.","severity":"deprecated","affected_versions":">=4.0.0"},{"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`.","message":"Improper 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Forgotten `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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"TypeError: Cannot read properties of undefined (reading 'send')"},{"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.","cause":"The provided password for the RCON server is incorrect.","error":"Error: RCON connection failed: Authentication failed."},{"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.","cause":"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.","error":"Error: connect ECONNREFUSED"}],"ecosystem":"npm"}