Time to move website to server / Discord webhook issue #27
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Discord webhooks not wanting to work. enoem and chatgpt says it's a ram issue basically. Been trying to clean it up but may just need to make an api on pico, and host the server elsewhere. May just do 2 different versions idk.
Time to move it to a website / Discord webhook issueto Time to move website to server / Discord webhook issueit would be nice to just have everything self-contained though. I mean how many people are running a server. May divulge this project down 2 lines if I have to. Give a try at forking and keeping most of it mostly the same but just porting out the website part. Tried to keep it mostly to it's on file anyways. The file would still have to be converted to talk to server and have an api. (web_server.py file) removed and possibly api.py file imported.
Did a lot of bs to get the webhooks working in its current state. need 100kb of memory just to hit a webhook. Would an api be any different. Trying to send shit through an api that will update. Or should I have the api on the pi, and have the website ping the api every so often. Can't think about it right right now.
Also would note i had to set a threshold of around 95000 bytes in order to get webhooks rolling. The pico in it's current state uses about 80-90kb of memory actively. Even with doing a lot of gc cleanup. in order to get the saving of schedules notification sent I have to del params, prev_schedules, prev call gc.collect() then try to pass webhook. Then i 'del schedules' to clear up some more room. Something about ssl and webhooks is the issue. So local hosting would be better. Or just run everything on regular pi. Because it would be a lot easier than this for real
The below is before anything is loaded and right after wifi connects. So not much is loaded yet technically.
DEBUG: Free RAM before Discord send: 165 KBAfter schedules and everything is loaded here is example:
So in order to run webhooks i need above 95kb of memory free at all times. Even though in my testing it took about 30-40kb of memory just for a single script to run a webhook.
Even though a simple webhook script may only use 30–40KB, you need much more free memory for reliable Discord webhook sends on MicroPython. Here’s why:
TLS/HTTPS Overhead
Memory Fragmentation
urequests) need a big, contiguous chunk for buffers.Temporary Objects
Garbage Collection Timing
gc.collect()right before sending, you maximize available memory.MicroPython’s Conservative Memory Checks
Summary:
If you want to experiment, you can lower the threshold, but you’ll see more ENOMEM errors and failed sends.