Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote console/chat via WebSocket #3152

Open
Mqxx opened this issue Nov 15, 2024 · 3 comments
Open

Remote console/chat via WebSocket #3152

Mqxx opened this issue Nov 15, 2024 · 3 comments

Comments

@Mqxx
Copy link

Mqxx commented Nov 15, 2024

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 🙂

@itzg
Copy link
Owner

itzg commented Nov 15, 2024

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 itzg/mc-server-runner#56

To set expectations, unless someone contributes this feature, I can't guarantee I'll add this any time soon or ever.

@Mqxx
Copy link
Author

Mqxx commented Nov 25, 2024

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.

@Mqxx
Copy link
Author

Mqxx commented Nov 25, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants