docker-minecraft-server
docker-minecraft-server copied to clipboard
Remote console/chat via WebSocket
Enhancement Type
A completely new feature
Describe the enhancement
Currently, the only way to connect to the server and send commands is to use the rcon-cli that your container provides. Rcon kinda sucks... And I mean specifically Rcon, not your implementation of rcon-cli. There is currently no better way to do it.
The problem with Rcon is that you can only retrieve the console output of the command you just ran, not the entire console output. This makes it difficult, for example, to build a WebUI or other applications that require the entire output. I think this is also the reason why many people currently rely on technologies like Screen or Tmux (which I also used before). Simply to get the live console.
It would be really great if you could implement a WebSocket hook that directly accesses the console in the server from the container so that you can get a live stream of the console and also send commands via WebSocket.
This way it would be possible to build better management tools that use this container to manage the server.
Thanks for consideration 🙂
I agree with the frustrations with RCON, but then it's just doing the command-response that it's designed for.
A websocket interface makes sense especially since docker and kubernetes use that to enable programmatic access to interact with containers. Speaking of which, keep in mind that the output of the Minecraft server can always be remotely retrieved via docker/kubernetes logs.
It could be done similar to https://github.com/itzg/mc-server-runner/pull/56
To set expectations, unless someone contributes this feature, I can't guarantee I'll add this any time soon or ever.
I will look into this. My idea was to implement a WebSocket server using for example Deno (JS/TS runntime) and watching latest.log using the build-in file watcher. This could also be packed into an other container, like a "plugin" for your container.
Sending commands would be done by sending it through WebSocket to the WebSocketServer and then the server would send it via Rcon to the Minecraft server.
Receiving commands would be done by listening on the latest.log for changes and if there are any, then the changes are send via WebSocket to the client.
That's currently the ony way (that I know) on how to "send and recive as raw as possible".
An other way would be to go directly with a Fabric mod (at least for my purpose, cause I use Fabric) that hooks into the log of Minecraft.
Just for tracking on which features would be nice to have for the WebSocket connection:
- [ ] Sending commands
- [ ] Receiving commands
- [ ] Query available commands
- [ ] Query possible auto completions for provided string (Ex. Sending "hel" would result in a response list like ["help", ...], but this could be implemented client side)
- [ ] (Optional: Query server stats, like CPU and RAM usage)