question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webhook stops transmitting data after some time

See original GitHub issue

The 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:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
r1bnccommented, Mar 23, 2021

UPDATE: The pull request worked! 😄 I now don’t need external script to restart the non responsive python script.

1reaction
r1bnccommented, Mar 22, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Problems with WebHooks - Zapier Help
This happens when trying to send data to the Zapier webhooks from inside a web browser and altering the Content-Type header during the...
Read more >
Complete Guide to Troubleshooting and Debugging Webhooks
The first thing you want to be sure of is that you are receiving your webhooks. Because webhooks are regular HTTP requests originating...
Read more >
A simple How-To on Webhooks: the intimidation stops now
It will have the data that we're sending it. So it's a good idea to check if it's NULL. If it is, then...
Read more >
Webhook suddenly not working - V3 Integrations
I have recently migrated my devices (home-brew nodes) and one gateway to V3. I have a webapp (self-made) which receives the data -...
Read more >
Stop Using Servers to Handle Webhooks | Square Corner Blog
It's always worth being sure that a webhook service offers some way to verify the data being sent, since it's possible for bad...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found