ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('162.159.134.233', 443)]

我们两清 提交于 2020-11-29 19:25:59

问题


So I was trying out making a bot in Discord and I tried running my discord bot over Gitpod and it was able to run, but when I tried running it on pythonanywhere.com, I get this error:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [Connect call failed ('162.159.134.233', 443)]

Here is a snippet of my code:

import discord
from discord.ext import commands
import json

with open("credentials.json") as creds:
    creds = json.loads(creds.read())
    TOKEN = creds["TOKEN"]

client = discord.Client()

class Bot(commands.Bot):
    def __init__(self):
        super(Bot, self).__init__(command_prefix="$", case_insensitive=True)
        self.pool = None

bot = Bot()

@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user)
    print('------')

# calculate
@bot.command()
async def calculate(ctx):
    await ctx.send("foo")

bot.run(TOKEN)

Any help would be greatly appreciated.


回答1:


Free accounts on PythonAnywhere can't use the Discord websockets API, but you can use their HTTP-based one. Take a look at the forum post that explains how to do that.



来源:https://stackoverflow.com/questions/61229697/clientconnectorerror-cannot-connect-to-host-discordapp-com443-ssldefault-con

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!