每次尝试 ping Minecraft 服务器时,Mcstatus 都会返回 ConnectionrRefuseError

时间:2021-01-06 17:53:49

标签: python discord.py discord.py-rewrite

我是 Minecraft 服务器和一般服务器的新手,我的朋友希望我帮助他为他的服务器制作一个不和谐的机器人。昨天我在 python 中遇到了这个模块调用 mcstatus,我决定用它从他的 Minecraft 服务器获取信息,看看它是否在线,但是每当我尝试连接到他的 mincraft 服务器时,它返回一个 ConnectionRefuseError: [ WinError 10061] 由于目标机器主动拒绝,无法建立连接,这是我的代码:

async def online(ctx):
    try:
        server = MinecraftServer.lookup("95.217.72.187:56043")
        status = server.status()
        await ctx.send(status)
    except:
        await ctx.send("server is offline")

错误是

Ignoring exception in command online:
Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:/Users/USER/PycharmProjects/untitled5/tcpe bot.py", line 51, in online
    status = server.status()
  File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\mcstatus\server.py", line 56, in status
    connection = TCPSocketConnection((self.host, self.port))
  File "C:\Users\USER\AppData\Roaming\Python\Python38\site-packages\mcstatus\protocol\connection.py", line 131, in __init__
    self.socket = socket.create_connection(addr, timeout=timeout)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 808, in create_connection
    raise err
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 796, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 859, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

任何人都知道为什么会发生这种情况,请帮助我尝试使用 mcipc 但它显示相同的错误为什么会发生这种情况是因为我的代码问题还是我的防火墙和其他东西

0 个答案:

没有答案