Skip to content

An async Minecraft RCON client library with support for fragmented responses.

License

Notifications You must be signed in to change notification settings

arvitus/aiomcrcon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aiomcrcon

Python Versions CodeFactor Grade PyPI - Version PyPI - Downloads

An async Minecraft RCON client library with support for fragmented responses.

Installing

pip install py-aio-mcrcon

Example

import asyncio
import aiomcrcon

async def main():
    # As context manager
    async with aiomcrcon.Client("myserver.com", "password") as client:
        response = await client.command("list")

    # Without context manager
    client = aiomcrcon.Client("myserver.com", "password") # port is optional, default is default RCON port
    await client.connect()
    response = await client.command("list")
    await client.close()

asyncio.run(main())

Documentation

Everything is properly type hinted and documented in the source code. Using the IDE of your choice, you should be able to get all the information you need. Otherwise, just take a look at the source code.

Fragmented responses

The Minecraft server implementation has a limit on the maximum response size of about 4096 bytes. If the response exceeds this limit, it will be split into multiple fragments. The client will automatically reassemble these fragments into a single response.
I do currently not know any other similar library that supports this feature.

Information regarding asyncio.gather()

The client does technically support asyncio.gather(), but in practice it will currently cause errors, because of a bug in the Minecraft server implementation. As long as this bug is not fixed, using the client with asyncio.gather() will execute the first command and return its response, but everything else will be ignored and the connection will be closed by the server. This causes all of the remaining or following commands to time out (raise TimeoutError) or wait indefinitely (based on timeout parameter). The client must be closed and connected to be used again.
This is not a bug in this library, but in the Minecraft server implementation!

Contributing

If you want to contribute to this project, feel free to open a pull request or issue.

About

An async Minecraft RCON client library with support for fragmented responses.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages