Trying to send requests from a Heroku dyno results in a connection error in python discord bots

Viewed 96

I have a bot which is retrieving information from a website online. When I run it normally or use repl.it the request goes through. However, I recently switched the bot over to heroku. Now it gives me a connection error.

import aiohttp
import discord
import asyncio

async with aiohttp.ClientSession() as s:
    async with s.get('https://mcuuid.net/?q=' + playername) as r:
        if r.status == 200:
            html = await r.text()
            ending = html.split('<input id="results_id" class="form-control click-select" readonly="readonly" value="')[1]
            UUID = ending.split('"></td></tr><tr><td><label for="results_raw_id">Trimmed UUID</label></td><td><in')[0]

            if UUID == "":
                await stext(msg, "No minecraft account found.")
                return
            else:
                await stext(msg, "Connection error. ")
                return

This is one snippet of the code I am using. I know my code works as using it on a different hosting service works. A connection error occurs on discord. I am wondering if Heroku blocks requests like pythonanywhere does. Any help would be appreciated!

0 Answers
Related