-1

Maybe I can find answers to my question here in the community. I run a somewhat more complex music bot and this got set up on a fresh server today.

Problem

I've been using Heroku for this bot for a while now and so far there have never been any problems. I then tried to set everything up again today because my hosting time has expired, starting it up also worked fine. But now the following:

I made the following changes in my requirements.txt file:

discord.py == 1.6.0 youtube_dl == 2021.1.24.1

Together with these settings the bot doesn`t even manage to hold out for 2 minutes and play the music properly. I always got only the following error message:

Shard ID 0 heartbeat blocked for more than 10 seconds.

I reported to the discord.py server, but on version 1.6.0 such changes causing this error were not introduced. So I thought that the problem is with the youtube_dl version. So I kept trying around, set discord.py == 1.5.1 and youtube_dl == 2021.1.8, but again Heroku seems to stop working at some point and now I get the following error code:

[WARNING] discord.gateway: Shard ID 0 has stopped responding to the gateway. Closing and restarting.

The bot stops responding, takes too long to start and I have to restart it manually. The funny thing: I also have a bot, which is only on one server and also runs via Heroku, there the errors also occurred, even with my old "settings", when the bot was still running on Heroku.

The latest and longest error I got:

2021-01-24T00:21:34.861555+00:00 app[worker.1]: [2021-01-24 00:21:34] [WARNING] discord.gateway: Shard ID 0 heartbeat blocked for more than 30 seconds.
2021-01-24T00:21:34.861568+00:00 app[worker.1]: Loop thread traceback (most recent call last):
2021-01-24T00:21:34.861568+00:00 app[worker.1]:   File "launcher.py", line 55, in <module>
2021-01-24T00:21:34.861568+00:00 app[worker.1]:     main()
2021-01-24T00:21:34.861569+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 1025, in __call__
2021-01-24T00:21:34.861569+00:00 app[worker.1]:     return self.main(*args, **kwargs)
2021-01-24T00:21:34.861569+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 955, in main
2021-01-24T00:21:34.861570+00:00 app[worker.1]:     rv = self.invoke(ctx)
2021-01-24T00:21:34.861570+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 1496, in invoke
2021-01-24T00:21:34.861571+00:00 app[worker.1]:     super().invoke(ctx)
2021-01-24T00:21:34.861571+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 1279, in invoke
2021-01-24T00:21:34.861571+00:00 app[worker.1]:     return ctx.invoke(self.callback, **ctx.params)
2021-01-24T00:21:34.861571+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 710, in invoke
2021-01-24T00:21:34.861572+00:00 app[worker.1]:     return callback(*args, **kwargs)
2021-01-24T00:21:34.861572+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/decorators.py", line 18, in new_func
2021-01-24T00:21:34.861572+00:00 app[worker.1]:     return f(get_current_context(), *args, **kwargs)
2021-01-24T00:21:34.861573+00:00 app[worker.1]:   File "launcher.py", line 51, in main
2021-01-24T00:21:34.861573+00:00 app[worker.1]:     run_bot()
2021-01-24T00:21:34.861573+00:00 app[worker.1]:   File "launcher.py", line 42, in run_bot
2021-01-24T00:21:34.861573+00:00 app[worker.1]:     bot.run()
2021-01-24T00:21:34.861573+00:00 app[worker.1]:   File "/app/bot.py", line 144, in run
2021-01-24T00:21:34.861574+00:00 app[worker.1]:     super().run(parser.get('DISCORD', 'token'), reconnect=True)
2021-01-24T00:21:34.861574+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/discord/client.py", line 698, in run
2021-01-24T00:21:34.861574+00:00 app[worker.1]:     loop.run_forever()
2021-01-24T00:21:34.861574+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/asyncio/base_events.py", line 541, in run_forever
2021-01-24T00:21:34.861575+00:00 app[worker.1]:     self._run_once()
2021-01-24T00:21:34.861575+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/asyncio/base_events.py", line 1786, in _run_once
2021-01-24T00:21:34.861575+00:00 app[worker.1]:     handle._run()
2021-01-24T00:21:34.861575+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/asyncio/events.py", line 88, in _run
2021-01-24T00:21:34.861575+00:00 app[worker.1]:     self._context.run(self._callback, *self._args)
2021-01-24T00:21:34.861576+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/discord/shard.py", line 151, in worker
2021-01-24T00:21:34.861576+00:00 app[worker.1]:     await self.ws.poll_event()
2021-01-24T00:21:34.861576+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/discord/gateway.py", line 564, in poll_event
2021-01-24T00:21:34.861576+00:00 app[worker.1]:     await self.received_message(msg.data)
2021-01-24T00:21:34.861576+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/discord/gateway.py", line 427, in received_message
2021-01-24T00:21:34.861577+00:00 app[worker.1]:     msg = self._zlib.decompress(self._buffer)
2021-01-24T00:21:34.861577+00:00 app[worker.1]: 
2021-01-24T00:21:39.861332+00:00 app[worker.1]: [2021-01-24 00:21:39] [WARNING] discord.gateway: Shard ID None voice heartbeat blocked for more than 20 seconds
2021-01-24T00:21:39.861369+00:00 app[worker.1]: Loop thread traceback (most recent call last):
2021-01-24T00:21:39.861370+00:00 app[worker.1]:   File "launcher.py", line 55, in <module>
2021-01-24T00:21:39.861371+00:00 app[worker.1]:     main()
2021-01-24T00:21:39.861371+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 1025, in __call__
2021-01-24T00:21:39.861372+00:00 app[worker.1]:     return self.main(*args, **kwargs)
2021-01-24T00:21:39.861372+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 955, in main
2021-01-24T00:21:39.861372+00:00 app[worker.1]:     rv = self.invoke(ctx)
2021-01-24T00:21:39.861373+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 1496, in invoke
2021-01-24T00:21:39.861373+00:00 app[worker.1]:     super().invoke(ctx)
2021-01-24T00:21:39.861373+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 1279, in invoke
2021-01-24T00:21:39.861374+00:00 app[worker.1]:     return ctx.invoke(self.callback, **ctx.params)
2021-01-24T00:21:39.861374+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/core.py", line 710, in invoke
2021-01-24T00:21:39.861375+00:00 app[worker.1]:     return callback(*args, **kwargs)
2021-01-24T00:21:39.861375+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/click/decorators.py", line 18, in new_func
2021-01-24T00:21:39.861375+00:00 app[worker.1]:     return f(get_current_context(), *args, **kwargs)
2021-01-24T00:21:39.861376+00:00 app[worker.1]:   File "launcher.py", line 51, in main
2021-01-24T00:21:39.861376+00:00 app[worker.1]:     run_bot()
2021-01-24T00:21:39.861376+00:00 app[worker.1]:   File "launcher.py", line 42, in run_bot
2021-01-24T00:21:39.861376+00:00 app[worker.1]:     bot.run()
2021-01-24T00:21:39.861376+00:00 app[worker.1]:   File "/app/bot.py", line 144, in run
2021-01-24T00:21:39.861377+00:00 app[worker.1]:     super().run(parser.get('DISCORD', 'token'), reconnect=True)
2021-01-24T00:21:39.861377+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/discord/client.py", line 698, in run
2021-01-24T00:21:39.861377+00:00 app[worker.1]:     loop.run_forever()
2021-01-24T00:21:39.861377+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/asyncio/base_events.py", line 541, in run_forever
2021-01-24T00:21:39.861378+00:00 app[worker.1]:     self._run_once()
2021-01-24T00:21:39.861378+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/asyncio/base_events.py", line 1786, in _run_once
2021-01-24T00:21:39.861378+00:00 app[worker.1]:     handle._run()
2021-01-24T00:21:39.861379+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/asyncio/events.py", line 88, in _run
2021-01-24T00:21:39.861379+00:00 app[worker.1]:     self._context.run(self._callback, *self._args)
2021-01-24T00:21:39.861379+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/discord/shard.py", line 151, in worker
2021-01-24T00:21:39.861379+00:00 app[worker.1]:     await self.ws.poll_event()
2021-01-24T00:21:39.861379+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/discord/gateway.py", line 564, in poll_event
2021-01-24T00:21:39.861380+00:00 app[worker.1]:     await self.received_message(msg.data)
2021-01-24T00:21:39.861380+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.7/site-packages/discord/gateway.py", line 427, in received_message
2021-01-24T00:21:39.861380+00:00 app[worker.1]:     msg = self._zlib.decompress(self._buffer)
2021-01-24T00:21:39.861380+00:00 app[worker.1]:

To the Python buildpack I have installed the following things:

https://github.com/xrisk/heroku-opus

https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest

Could the error be due to these buildpacks, although it always worked before? I just don't know at the moment, because of course everything works locally. Also upgrading to newer modules or versions from my requirements.txt file always causes problems with Heroku or doesn't let the bot start.

Is there a recommendation which python version to use with Heroku? Currently I define with a runtime.txt the version 3.7.9. Note that all the errors just appear on Heroku, local is working fine.

1
  • Welcome to SFSE. Generally, questions about the Heroku platform are on topic here (as it is a Salesforce product), but questions about Discord and Python in general are not, and belong to another community like Stack Overflow. Right now, I think it's unclear which bucket this problem falls into, but I'd suggest that pragmatically you may have more success in a Discord + Python community.
    – David Reed
    Jan 26 at 19:34
0

BTW this is the wrong forum for python discord bot questions, you may want to consider reaching out to the Discord community for writing Discord bots in Python, here: https://discord.gg/r3sSKJJ

I’ve written some discord python bots for heroku before. From my experience years ago, my free heroku would work for a while until credits were consumed and at that point my bot would stop responding. Do check the latest docs

Other questions: what do you mean “ I then tried to set everything up again today” what exactly did you change? You should use git to compare your last known working state to whatever your broken state is, to see if any diffs jump out to blame. If that doesnt help, it could be that a server variable changed on the heroku side

2
  • Perhaps a little confusing on my part. Here then the clarity: Other bots, which have nothing to do with music, work fine. I didn't change anything in the settings/code at first, set it up again with the same code and it stopped working, so I was puzzled. Is there anywhere to see the changes? (I use GitHub Desktop and did not deploy any changes there, also not in GitHub.)
    – Dominik
    Jan 26 at 9:42
  • Hopefully you have commits to compare to to help pinpoint the issue or rule issues out. From my experience years ago, my free heroku would work for a while until credits were consumed and at that point my bot would stop responding. Do check the latest docs and good luck. BTW @moderators are welcome to close this as its not SFSE related. Jan 26 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.