在Python Anywhere上运行我的Discord Bot时出错

问题描述 投票:0回答:1

我使用Python 3.6制作了Discord Bot。它在我的计算机上运行时运行良好,但是当我在PythonAnywhere上运行它时,我得到了这条消息。我安装了Discord.py和所有必要的模块。请帮忙。我对复杂的编程谈话并不是很好,对网络谈话也不是很好,所以请尽可能简单地回答。这个问题只发生在PythonAnywhere或所有远程托管站点吗?

01:42 ~ $ python3.6 MyCoolBot.py
Traceback (most recent call last):
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 601, in _create_direc
t_connection
    local_addr=self._local_addr)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 778, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.6/asyncio/base_events.py", line 765, in create_connection
    yield from self.sock_connect(sock, address)
  File "/usr/lib/python3.6/asyncio/selector_events.py", line 450, in sock_connect
    return (yield from fut)
  File "/usr/lib/python3.6/asyncio/selector_events.py", line 480, in _sock_connect_cb
    raise OSError(err, 'Connect call failed %s' % (address,))
ConnectionRefusedError: [Errno 111] Connect call failed ('104.16.58.5', 443)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 304, in connect
    yield from self._create_connection(req)
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 578, in _create_conne
ction
    transport, proto = yield from self._create_direct_connection(req)
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 624, in _create_direc
t_connection
    (req.host, req.port, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 111] Can not connect to discordapp.com:443 [Connect call failed ('104.16.
58.5', 443)]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "MyCoolBot.py", line 39, in <module>
    client.run('MY_BOT_TOKEN')
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 519, in run
    self.loop.run_until_complete(self.start(*args, **kwargs))
  File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
    return future.result()
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 490, in start
    yield from self.login(*args, **kwargs)
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 416, in login
    yield from getattr(self, '_login_' + str(n))(*args, **kwargs)
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/client.py", line 346, in _login_1
    data = yield from self.http.static_login(token, bot=is_bot)
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/http.py", line 258, in static_login
    data = yield from self.request(Route('GET', '/users/@me'))
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/discord/http.py", line 137, in request
    r = yield from self.session.request(method, url, **kwargs)
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/client.py", line 555, in __iter__
    resp = yield from self._coro
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/client.py", line 198, in _request
    conn = yield from self._connector.connect(req)
  File "/home/CompuGenius/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 314, in connect
    .format(key, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 111] Cannot connect to host discordapp.com:443 ssl:True [Can not connect to discordapp.com:443 [Connect call failed ('104.16.58.5', 443)]]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f4b25d81be0>
python bots discord discord.py pythonanywhere
1个回答
1
投票

这是因为PythonAnywhere需要一个代理,使得aiohttp websockets不支持。他们的论坛上有一个关于它的帖子:https://www.pythonanywhere.com/forums/topic/7384/

© www.soinside.com 2019 - 2024. All rights reserved.