home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.09k stars 30.18k forks source link

Minecraft Server Integration No Longer Works to Server On Local Network After Update #106631

Closed codahq closed 1 week ago

codahq commented 9 months ago

The problem

I'm not sure which update to the Minecraft Server broke connectivity. What I know:

Additional information:

What version of Home Assistant Core has the issue?

core-2023.12.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Minecraft Server

Link to integration documentation on our website

https://www.home-assistant.io/integrations/minecraft_server

Diagnostics information

Because it's not establishing the integration I don't know how to get integration specific logs. However, if I create an integration to another server and then try to add another server I can at least put the integration in debug log mode. This is what it says when I do that and try to create an integration to the server that always fails.

image

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 9 months ago

Hey there @elmurato, mind taking a look at this issue as it has been labeled with an integration (minecraft_server) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `minecraft_server` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign minecraft_server` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


minecraft_server documentation minecraft_server source (message by IssueLinks)

elmurato commented 9 months ago

If you're familiar with Python, could you please try reading information using the Python package mcstatus? You can install it via pip. You can find the documentation here.

codahq commented 9 months ago

I'm not very familiar but I'll figure it out for this and report back soon.

elmurato commented 9 months ago

Can you also please check if the setting enable-status is set to true in your server.properties on the server side?

elmurato commented 9 months ago

@home-assistant add-label needs-more-information

elmurato commented 9 months ago

Sorry for spamming, but you could also re-test it with the upcoming HA core release 2024.1.3. It will include a fix for a problem with newer server versions.

What is your server version? 1.19.x/1.20.x or older?

issue-triage-workflows[bot] commented 8 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

slaygirlz commented 8 months ago

@codahq your not alone im having the same issue

elmurato commented 8 months ago

@progamer562 Since you're also affected, could you give me the information I am awaiting from @codahq? Thanks.

slaygirlz commented 8 months ago

oh yes sure what you would need. to fix this

elmurato commented 8 months ago

Great, thanks. Basically all questions I asked above.

codahq commented 8 months ago

If you're familiar with Python, could you please try reading information using the Python package mcstatus? You can install it via pip. You can find the documentation here.

sorry for the delay. not a lot of free time to fix non-essentials, you know?

mcstatus had no problem reading data from the server. i didn't think it would because i essentially use a javascript version of this library to pull status for a webpage. i can also use any of the public web services to pull status from the server. (and as i mentioned before i used this integration previously)

image image

the screenshots show that both protocols are configured on the server (i think). the problem is definitely at the home assistant level. what can i provide from my home assistant environment to help?

elmurato commented 8 months ago

No problem 🙂

The query protocol is not supported yet in the HA integration. Could you please re-run the command with the status protocol?

mcstatus 10.10.10.5:63001 status

codahq commented 8 months ago

after i posted i immediately realized you would ask that. i updated my last post probably while you were typing your reply

elmurato commented 8 months ago

Okay then from server point of view everything is fine. Good.

Next: Did you retry with HA core 2024.1.3 or newer? It included a fix for newer server version like yours. Additionally it gives now better debug messages if the setup fails.

codahq commented 8 months ago

i'm on 2024.1.5 currently. i did try again but i didn't have debug output turned on. i've done that now though and the result is the same.

image

elmurato commented 8 months ago

I'm so stupid, forgive me, my fault. The improved debug messages will probably be in the next major HA core release. It's not in the current releases yet. That's why you don't see any difference.

Since the next major release is just around the corner, I would propose that you retest with 2024.2.0 once it's available and recheck the debug messages. Hopefully we will get a good hint.

Or if you open your server to the outside and send me the server address via Discord, I could test it for you with my dev environment.

slaygirlz commented 8 months ago

my server is open to the world wide web

codahq commented 8 months ago

I'm so stupid, forgive me, my fault. The improved debug messages will probably be in the next major HA core release. It's not in the current releases yet. That's why you don't see any difference.

Since the next major release is just around the corner, I would propose that you retest with 2024.2.0 once it's available and recheck the debug messages. Hopefully we will get a good hint.

Or if you open your server to the outside and send me the server address via Discord, I could test it for you with my dev environment.

no apologies necessary. i will retest next version.

as a side note, i am fairly confident that an external home assistant environment will be able to connect to my server. i think the issue is in how home assistant makes local connections potentially.

do you happen to have the ability to setup a local minecraft server? if so, is your HA running supervised? do integrations have to do anything to be able to communicate locally? i have no idea how the architecture works for home assistant OS but if it's just a vm running containers i could see it introducing a network layer where communication to local network devices could be blocked.

I could be wrong but i've not had a problem with the minecraft integration monitoring an external minecraft server. it's only servers on my LAN that it can't seem to see.

elmurato commented 7 months ago

do you happen to have the ability to setup a local minecraft server? if so, is your HA running supervised? do integrations have to do anything to be able to communicate locally? i have no idea how the architecture works for home assistant OS but if it's just a vm running containers i could see it introducing a network layer where communication to local network devices could be blocked.

I am running Paper 1.16.4 (local IP 192.168.x.y) on Pterodactyl and HA OS both as VMs inside Proxmox, with no issues.

HA core 2024.2 is now live. Please re-test with it. Thanks!

codahq commented 7 months ago

Tested and confirmed still not working. The error is the same as before where I posted that it tries both a bedrock and then java server and times out on both.

image

Help me understand how the networking works for integrations. Are they containerized or segregated from the LAN network interface in some way? This integration was working just fine and now has stopped because of connectivity issue. Keep in mind these points.

Does HA treat 192.168.x.y differently than other local IP address ranges like 10.10.x.y?

elmurato commented 7 months ago

I was expecting that with the new version it would still not work. But I was interested in the now more detailed debug messages. Unfortunately, we now just get a TimeoutError, which doesn't really help understanding the problem further.

Home Assistant can ping the minecraft server via the Ping (ICMP) integration

It really looks like that your HA instance cannot access your local server (at least not via the status protocol). Which IP address has your HA instance? Is it in the same subnet? Did you change anything in your network hardware, like your router? Are you using VLANs or something like this which might block the status request from HA to your MC server?

Other external server status libraries can read the minecraft server

How does this work with your local server? Is it also open to the outside of your network?

Help me understand how the networking works for integrations. Are they containerized or segregated from the LAN network interface in some way? This integration was working just fine and now has stopped because of connectivity issue.

Unfortunately I don't know how the networking layer works in detail in HA. But I can try to find help on Discord.

codahq commented 7 months ago

It really looks like that your HA instance cannot access your local server (at least not via the status protocol). Which IP address has your HA instance? Is it in the same subnet? Did you change anything in your network hardware, like your router? Are you using VLANs or something like this which might block the status request from HA to your MC server?

There are no VLANs. They are both on the same subnet; the Minecraft server is at 10.10.10.5 and the hass-os is sitting at 10.10.10.200 or something like that. Since there are no VLANs and there is only one subnet and it's just a standard home type router I don't think any of that is the problem. They are on different switches but as a test I put them on the same switch just now and the problem still exists.

How does this work with your local server? Is it also open to the outside of your network?

I have made it public for testing this issue and the configuration of query and status periodically. Always the testing is successful and the server is configured correctly.

Is there anything other than the Ping integration that I can do to prove that HA can see the minecraft server? For example, from my computer or any device on my LAN I can also telnet the port of the minecraft server and get a connection. I noticed I can setup telnet in configuration.yaml but I don't know if it's setup in a way that I could use it to just test connectivity.

To add to this, I haven't made any network changes. The router is the same for many years and I haven't changed any settings there. I have some switches attached to it but those have not changed for many years either. That is why I think this is related to a change in HA or the MC integration.

codahq commented 7 months ago

I remembered something by the way. I know which version it completely stopped working. It was the next version after I reported having this issue .

https://github.com/home-assistant/core/issues/90485

Did you change the timeout to be longer or shorter? If you decreased the timeout, it is it possible that the status request always fails. I have no idea why the ping would take so long either. Everything else is immediate (including telnet and mcstatus from my workstation to the minecraft server). Is there a possibility that the hass-os installation is unhealthy or has a long network queue because of something else going on? I don't see any other traces of unhealthiness or slowdowns but maybe these requests go in a different queue than the ones I can notice.

issue-triage-workflows[bot] commented 7 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

slaygirlz commented 7 months ago

no

issue-triage-workflows[bot] commented 6 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

bwente commented 6 months ago

Looking for a solution.

codahq commented 6 months ago

@elmurato are there additional layers of debugging we can see anywhere? did you happen to try anybody in discord? i floated teh question a week or so ago in the integrations channel but nobody responded.

Tonguc-Endem commented 6 months ago

I just removed the non-working server entry and added a new entry for the same server with the same settings and it started working.

codahq commented 6 months ago

I just removed the non-working server entry and added a new entry for the same server with the same settings and it started working.

there haven't been any changes to the integration but regardless i tested this again in case it was platform changes and it did not work. this is something i have done probably a hundred times during troubleshooting.

issue-triage-workflows[bot] commented 5 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

codahq commented 5 months ago

this makes me sad. this has to be an issue with home assistant or this integration. the underlying library that this integration uses works without any issue. there is something in the implementation, a restriction, configuration, etc. that is preventing this from working. i've checked my system load and its extremely low on cpu and ram. disk space is extremely fast.

and this was working without any changes until a home assistant upgrade of minecraft integration upgrade.

i've asked in the discord and here. is the only help i'm going to get to learn everything about everything and figure this out myself? i think it's clear that i've shown this is a problem in home assistant from the information above.

issue-triage-workflows[bot] commented 5 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

elmurato commented 5 months ago

this makes me sad. this has to be an issue with home assistant or this integration. the underlying library that this integration uses works without any issue. there is something in the implementation, a restriction, configuration, etc. that is preventing this from working. i've checked my system load and its extremely low on cpu and ram. disk space is extremely fast.

and this was working without any changes until a home assistant upgrade of minecraft integration upgrade.

i've asked in the discord and here. is the only help i'm going to get to learn everything about everything and figure this out myself? i think it's clear that i've shown this is a problem in home assistant from the information above.

Sorry for the long delay. I just asked for support in the Discord server. Hopefully someone is willing to help. I'm unfortunately at the end of my debugging capabilities here. Don't know much about the network layer in HA core.

PS: To avoid this issue to be closed by the bot please always just comment something once the bot adds the stale label.

elmurato commented 5 months ago

@home-assistant remove-label needs-more-information

elmurato commented 5 months ago

I remembered something by the way. I know which version it completely stopped working. It was the next version after I reported having this issue .

90485

Did you change the timeout to be longer or shorter? If you decreased the timeout, it is it possible that the status request always fails. I have no idea why the ping would take so long either. Everything else is immediate (including telnet and mcstatus from my workstation to the minecraft server). Is there a possibility that the hass-os installation is unhealthy or has a long network queue because of something else going on? I don't see any other traces of unhealthiness or slowdowns but maybe these requests go in a different queue than the ones I can notice.

Timeouts should be longer now.

mib1185 commented 5 months ago

Sorry for the long delay. I just asked for support in the Discord server. Hopefully someone is willing to help. I'm unfortunately at the end of my debugging capabilities here. Don't know much about the network layer in HA core.

let us first collect some more details about the environment of the users - so @all please provide following details

codahq commented 5 months ago
  • Was it working an an earlier version of HA core?

Yes, I had the integration setup initially to announce to my kids when their cousins joined our server. It setup initially and ran for quite a while without any issues. Eventually the integration failed ever see the server and the entities were always unavailable. I deleted the integration and it will no longer setup and fails as I've described above.

  • Please provide the full system information from "Settings > System > Repairs > 3-dot-menu on top right corner > System information" click on copy and paste it "as is" here in a comment

I will paste this in the next comment.

  • If you're on HA-OS or supervised, please open the terminal add-on and provide output of the following command: replace SERVERIP and PORT with the ipP and the port of your minecraft server
    nc -v -z SERVERIP PORT

image

codahq commented 5 months ago

System Information

version core-2024.5.0
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.25-haos
arch x86_64
timezone America/Denver
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1411 Downloaded Repositories | 21
AccuWeather can_reach_server | ok -- | -- remaining_requests | 41
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.2 -- | -- update_channel | stable supervisor_version | supervisor-2024.04.4 agent_version | 1.6.0 docker_version | 25.0.5 disk_total | 228.5 GB disk_used | 34.8 GB healthy | true supported | true board | generic-x86-64 supervisor_api | ok version_api | ok installed_addons | Mosquitto broker (6.4.0), Samba share (12.3.1), Ring-MQTT with Video Streaming (5.6.4), Z-Wave JS (0.5.0), Z-Wave JS UI (3.6.0), Advanced SSH & Web Terminal (17.2.0), ESPHome (2024.4.2), AdGuard Home (5.0.7), Log Viewer (0.17.0), Uptime Kuma (0.12.1), WireGuard (0.10.2), Matter Server (5.6.0), Zigbee2MQTT (1.37.0-1)
Dashboards dashboards | 22 -- | -- resources | 14 views | 24 mode | storage
Recorder oldest_recorder_run | April 25, 2024 at 6:45 AM -- | -- current_recorder_run | May 1, 2024 at 7:54 PM estimated_db_size | 561.12 MiB database_engine | sqlite database_version | 3.44.2
mib1185 commented 5 months ago

image

this indicates, that the HA-OS can reach and connect to the minecraft server on port 63001 - means on network layer the connection (more precisely the tcp connection) works properly. So the issue might be on protocol level - maybe changes in the api of the minecraft server (did you update it lately?)

mib1185 commented 5 months ago

next would be enabling debug logging for minecraft_server and it's dependencies ... to do so add the following to your configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.minecraft_server: debug
    dnspython: debug
    mcstatus: debug

afterwards reload the integration, wait until the error happens, than download and provide the full home-assistant.log

Note: it is better to drag the log into the comment (which will add it as an attachment) and not copy paste as it is hard to read logs in GitHub.

bwente commented 4 months ago

I updated HA (Release 2024.5.5) last night and restarted both HA and Minecraft and it is now working.

codahq commented 4 months ago

next would be enabling debug logging for minecraft_server and it's dependencies ... to do so add the following to your configuration.yaml:

logger:
  default: info
  logs:
    homeassistant.components.minecraft_server: debug
    dnspython: debug
    mcstatus: debug

afterwards reload the integration, wait until the error happens, than download and provide the full home-assistant.log

Note: it is better to drag the log into the comment (which will add it as an attachment) and not copy paste as it is hard to read logs in GitHub.

that didn't seem to add anything additional that we weren't already seeing to my logs. do i have to do more than restart? home-assistant.log

mib1185 commented 3 months ago

@elmurato is it common that the it first tries the Bedrock Edition and than the Java Edition? if both cases the initialization seems to be successful, but fetching data runs into timeout - this looks like an application layer issue

logfile from above as reference:

2024-06-03 20:40:41.124 DEBUG (MainThread) [homeassistant.components.minecraft_server.api] Initialized Bedrock Edition server instance with address '10.10.10.5:63001'
2024-06-03 20:41:11.132 DEBUG (MainThread) [homeassistant.components.minecraft_server.api] Connection check of Bedrock Edition server failed: Status request to '10.10.10.5:63001' failed: TimeoutError()
2024-06-03 20:41:11.132 DEBUG (MainThread) [homeassistant.components.minecraft_server.api] Initialized Java Edition server instance with address '10.10.10.5:63001'
2024-06-03 20:41:41.140 DEBUG (MainThread) [homeassistant.components.minecraft_server.api] Connection check of Java Edition server failed: Status request to '10.10.10.5:63001' failed: TimeoutError()
elmurato commented 3 months ago

@mib1185 Yes, the integration first tries to connect to a Bedrock server and if that fails tries again to connect to a Java server. Reason is that some Bedrock servers mimic a Java server.

mib1185 commented 3 months ago

maybe adding some further debug logging to mcstatus may help to find the root cause, but also checking the server side logs (I'm not familiar with minecraft servers, so unfortunately I can't support with it)

codahq commented 3 months ago

may help to find the root cause, but also checking the server side logs (I'm not familiar with minecraft servers, so unfortunately I can't support with it)

this part might be tricky. i see nothing in the server logs or console when any other library successfully pulls a status or fails to pull a status. i'm not sure if the minecraft side will be very helpful in that regard. maybe somebody can tell me if there's a way to crank up verbosity in some way to see query requests in the log. i couldn't find a way to do it with some preliminary googling.

issue-triage-workflows[bot] commented 2 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.