gekware/minecraft-server-hibernation

msh query protocol support (used by home assistant)

Closed this issue · 13 comments

Services like Home Assistant (and better game server monitoring sites and tools) don't report anything correctly when the MC server is stopped. Would it be possible to capture things like server message, protocol, version, max player count when the server is online and return it with current player count 0 to whatever protocol and port is used to query servers?

This way the server still appears to be online to Home Assistant and other services when it is asleep because it is reachable after it warms up.

msh is already doing so.

When ms is frozen, msh emulates a server info response whenever a client refreshes its server page. (showing 0 players, version, ping, and the specified frozen MOTD)

In which version? The latest release version returns no information and Home Assistant's monitoring implementation sets it to offline while it is hibernating.

What do you mean "sets it offline"?

Is the assistant configured correctly, with right msh address/port?

How is the assistant retrieving the ms informations?

https://github.com/py-mine/mcstatus/blob/master/mcstatus/server.py

It looks like Home Assistant uses query protocol? Does the Minecraft game client use a different protocol to get server information?

msh is using main minecraft server TCP port to perform status response and is capable of emulating it when minecraft server is offline (https://wiki.vg/Protocol#Status)

Home Assistant is using query protocol instead, which msh does not implement (https://wiki.vg/Query)


maybe you can set the Home Assistant to perform requests as status request on main minecraft server TCP port?

edit: I think MCStatus supports a status request (look here)

added a test query handler here: 49a1ff3

thank you for the reply and looking at this more with me. yes, i could do a PR to the home assistant team and ask them to update the method in which they poll the minecraft server to use TCP status instead of query. i don't think a PR like that would be approved unfortunately. they would even reference maybe your link to suggest that query protocol is the appropriate method.

that is why i came to your project. i am grateful that you have already even added a test handler. do you think that you will continue to add query support?

could do a PR to the home assistant team and ask them to update the method in which they poll the minecraft server to use TCP status instead of query. i don't think a PR like that would be approved unfortunately. they would even reference maybe your link to suggest that query protocol is the appropriate method.

well I think that the 2 methods are different and independent, if you look at server.properties you can enable/disable them independently. It would for sure make the home assistant service more complete especially because the query method is disabled by default on vanilla servers and only the status method is enabled.

that is why i came to your project. i am grateful that you have already even added a test handler. do you think that you will continue to add query support?

I opened a branch cause I think it's pretty doable, especially with the great documentation online. It feels good to be back adding stuff and not only removing code and bugs XD

@codahq can you compile query branch and test if the test query handler is working?

in server.properties just set query.port to be equal to server-port, launch msh and check if the home assistant can see a response (provided that home assistant does the query on the same server port)

i don't have a development environment for go but i can set one up if you don't have a binary for me to download.

you can download msh-v2.4.10-1fc94c0.zip

If you need an other arch tell me

functionality was added at 1b2c2fe

@codahq would you mind doing some bughunt?