python-valve rcon minecraft 'ConnectionRefusedError: [Errno 111] Connection refused'

python-valve rcon minecraft 'ConnectionRefusedError: [Errno 111] Connection refused'

我正在尝试使用 python-valve 连接到我自己网络上托管的 Minecraft 服务器上的 RCON。我的代码如下(请记住它只能在我的网络上访问,因此我连接到本地主机):

import valve.rcon
def rconsendCMD():
    address = ("127.0.0.1", 25575)
    valve.rcon.execute(address,"jeff","time set night")

根据文档,该代码应该可以正常工作 returns:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "bot.py", line 90, in on_message
    rconsendCMD()
  File "bot.py", line 43, in rconsendCMD
    valve.rcon.execute(address,"jeff","time set night")
  File "/usr/local/lib/python3.6/site-packages/valve/rcon.py", line 630, in execute
    with RCON(address, password) as rcon:
  File "/usr/local/lib/python3.6/site-packages/valve/rcon.py", line 325, in __enter__
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/valve/rcon.py", line 464, in wrapper
    return function(instance, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/valve/rcon.py", line 464, in wrapper
    return function(instance, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/valve/rcon.py", line 483, in connect
    self._socket.connect(self._address)
ConnectionRefusedError: [Errno 111] Connection refused

可以找到 'valve.rcon.execute()' 的文档 here

我发现了问题。我将服务器托管在与执行 python 代码的机器不同的机器上。我试图将它发送到本地主机而不是我网络中的私人地址。已找到答案