py-mine / mcstatus

A Python library for checking the status of Minecraft servers
https://mcstatus.readthedocs.io
Apache License 2.0
478 stars 37 forks source link

Transport Endpoint is not connected when run on linux #577

Closed KarsonTheFoxx closed 1 year ago

KarsonTheFoxx commented 1 year ago

I get this as an error while using my bot on a Linux machine, however not windows.

Specifically raspberry pi OS 32 bit and windows 10 pro

KarsonTheFoxx commented 1 year ago

Both https://mcsrvstat.us, and https://mcstatus.io/status work and so does running it on windows

kevinkjt2000 commented 1 year ago

Sounds like this Linux machine has an outgoing firewall

kevinkjt2000 commented 1 year ago

Not enough information without a stacktrace, code, version of mcstatus, and firewall setup of the raspberry pi.

PerchunPak commented 1 year ago

Please also provide server public IP (if it's public) and try to get status with https://statusmc.perchun.it (it uses mcstatus under the hood, so this eliminates the problem in your computer setup).

kevinkjt2000 commented 1 year ago

With the lack of information, I will assume this is a duplicate of #538.

KarsonTheFoxx commented 1 year ago

Sorry, got busy with work. The website that uses mcstatus works fine, and pi has default firewall configuration the code is just a copy + paste of the example minus the ping

KarsonTheFoxx commented 1 year ago

The code is just that thrown into a disnake / command

PerchunPak commented 1 year ago

The code is just that thrown into a disnake / command

Don't really understand what you mean. Just send code and traceback, it would be much better.

ItsDrike commented 1 year ago

pi has default firewall configuration

What exactly is that configuration?

the code is just a copy + paste of the example minus the ping

The example in readme includes a query request, query needs to be enabled on the server, and utilizes UDP. It's possible that the firewall configuration prevents UDP here, or that the server you're trying to obtain query data from simply doesn't have query enabled (you need to set enable-query=true in server.properties)

KarsonTheFoxx commented 1 year ago

pi has default firewall configuration

What exactly is that configuration?

the code is just a copy + paste of the example minus the ping

The example in readme includes a query request, query needs to be enabled on the server, and utilizes UDP. It's possible that the firewall configuration prevents UDP here, or that the server you're trying to obtain query data from simply doesn't have query enabled (you need to set enable-query=true in server.properties)

Ok, I see how that could be an issue but the problem is that the code works from a different device

ItsDrike commented 1 year ago

That just means the raspberry pi likely has a firewall which prevents the connection. I don't know what the firewall configuration of raspberry pi is, so I can't tell you much more here, however it is clear that this is not an issue with mcstatus, rather with the configuration of your device. If you do need some more help, feel free to ask on our discord server: https://discord.gg/C2wX7zduxC

KarsonTheFoxx commented 1 year ago

I have 2 raspberry pi 4's both with raspiOS 32 bit. Both are using default settings for wireless wifi, the issue is pi 1 gets that error, despite my pc having the program and it works

KarsonTheFoxx commented 1 year ago

Disnake is kinda unrelated to the problem

KarsonTheFoxx commented 1 year ago

I also can't send a stack trace because I lost the power cord for the pi that's throwing the error. I can however send the code

ItsDrike commented 1 year ago

I also can't send a stack trace because I lost the power cord for the pi that's throwing the error. I can however send the code

That won't really help us considering it works on another device, again, this is not an issue with mcstatus, it's an issue with the configuration of your device.

KarsonTheFoxx commented 1 year ago
from disnake.ext import commands
import disnake
from mcstatus import JavaServer

class minecraft(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.slash_command(name="status", description="Get minecraft server status")
    async def status(inter:disnake.CommandInteraction):
        await inter.response.defer()
        try:
            server = JavaServer.lookup("my server", 19132)
            query = server.query()

            emb = disnake.Embed(title=f"Server status", description="The server is Currently Online!", color=disnake.Color.green())

            emb.add_field(name=f"{query.players.online}/{query.players.max} Online", value=f"{', '.join(query.players.names)}")
        except TimeoutError:
            emb = disnake.Embed(title="The server is offline", color=disnake.Color.red())

        await inter.followup.send(embed=emb)

def setup(bot):
    bot.add_cog(minecraft(bot))
KarsonTheFoxx commented 1 year ago

I refuse to give tge ip as the ip is unprotected and traces directly back to my home ip, I edited out the ip and deleted its context for my safety

ItsDrike commented 1 year ago

If this same code works on another device, it's clear that query is enabled on the server, and the issue is that the raspberry pi just can't connect to it, this could be because of it's internal firewall configuration (likely blocking UDP), or a network-wide firewall, maybe it's on a VLAN that doesn't allow connections elsewhere, or maybe it's the device where the minecraft server is hosted that has the IP of the raspberry pi blocked.

KarsonTheFoxx commented 1 year ago

But it's trying to connect via the same ip on both devices from the same network

PerchunPak commented 1 year ago

Please, stop. We can't help with your firewall here, it is just not the right place.