Dinnerbone / mcstatus

A Python class for checking the status of an enabled Minecraft server

Home Page:http://dinnerbone.com/minecraft/tools/status/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

minecrafBedrockServer failing to connect to a server

KarsonTheFoxx opened this issue · comments

While making a discord bot that has a feature that displays the current ping and number of players on the server it keeps returning a TimeoutError despite me being able to join the server myself. ive checked the ip and port multiple times and have tried both entering the server information as minecraftBedrockServer(ip=ip, port=port) and minecraftBedrockServer("{0}:{1}".format(ip, port))

if you're wondering heres my code

try:
  mcServer = MinecraftServer(f"{server['ip']}:{server['port']}")
  status = mcServer.status()
  emb2 = discord.Embed(title="Server status", description="current status of the server", color=discord.Colr.green())
  emb2.add_field(name="players online", value="{0}/{1}".format(status.players_online, status.players_max))
  emb2.add_field(name="replied in", value="{0}MS".format(round(status.ping()*100, 1)))
except TimeoutError:
  emb2 = discord.Embed(title="Servers offline", description="no data available", color=discord.Color.red())

This is most likely due to a network issue or misconfiguration. Check port forwarding or your firewall(s), you've probably done something weird there. Also, MinecraftBedrockServer does take the host and port as separate arguments, not a single string.

The example code is showing MinecraftServer instead of MinecraftBedrockServer. There's a note about trying minecraftBedrockServer(ip=ip, port=port), but that casing is incorrect.

Have you tried running this code without the overhead of a discord bot? I would verify that the machine running the discord bot is capable of a simplified script first, then layer in the complexities of the discord bot.

Probably there's a firewall issue somewhere along the way.

Closing, as there has been no response for a while on this.