Webhook stops transmitting data after some time
See original GitHub issueThe webhook stops transmitting data to Discord after a while. It happened thrice now, the first one happened after the script has been running for 12 hours, the second one the script is running for 9 hrs, and now after 7 hrs.
The output is just stuck to:
Uploaded: [ last data in discord ]
And the data at discord channel shows: last data in discord
.
No exceptions have been triggered.
I have the excerpt of the script, more info can be found on my gitlab with the project entitled: chat-uploader-discord-webhook
. Beware it’s not pretty and doesn’t follow PEP8.
# tail a log file
# sleep_time is default to 1
# chat_message is the one being fetched from a log file
# VERBOSE is set to True
time.sleep(sleep_time)
webhook = DiscordWebhook(url=webhookurl, content=chat_message)
webhook_execute = webhook.execute()
# Credits: https://github.com/novasz @ https://github.com/lovvskillz/python-discord-webhook/issues/47
# Check if webhook response is 200/204
if webhook_execute.status_code in [200, 204]:
if VERBOSE:
print("Uploaded: [" + chat_message + "]\n")
# We are being rate limited :(
if webhook_execute.status_code == 429:
errors = json.loads(webhook_execute.content.decode('utf-8'))
wh_sleep = (int(errors['retry_after']) / 1000) + 0.15
print("Webhook rate limited: sleeping for " + str(wh_sleep) + " seconds...")
# Sleep
time.sleep(wh_sleep)
# Upload rate limit hit message, discard other messages
webhook = DiscordWebhook(url=webhookurl, content=rate_limit_message)
webhook_execute = webhook.execute()
if webhook_execute.status_code in [200, 204]:
if VERBOSE:
print("Notify Ratelimit was hit\n")
# hmm add if 429 here?
I will update the script later, or maybe just add another script that will terminate the python script after a set time interval and restart it.
Please confirm whether others can reproduce this problem or its just my code problem. Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
UPDATE: The pull request worked! 😄 I now don’t need external script to restart the non responsive python script.
Hi @vremes,
Thanks for informing me about the pull request, I will try this and monitor through the entire day. Currently busy at things but I will do my best to get back to you.