Hello,
I need to be able to upload HTTP Posts that are a minimum of 256KiB from an ESP8266. I’m reading a large file from external SPI flash. Originally the main problem was that we did not have enough ram to buffer the entire Post request, so I broke the request into multiple TCP packets.
However, Mongoose is just taking these requests and adding them to an internal queue within the struct mg_connection
, and so I run into the same problem, where we run out of memory.
More specifically, I have a for loop in an event handler that calls mg_send
repeatedly. So what I need is a way to either make mg_send a blocking function that only returns once the TCP packet has actually been sent, or a way to know when to stop queuing packets and resume once there is space in the send queue again.
- My goal is: Upload a large HTTP POST request in multiple TCP packets in order to conserve RAM
- My actions are: I call
mg_send
on small chunks of memory during the request - The result I see is: A large file causes Out Of Memory errors due to the messages being queued internally
- My expectation & question is: To send the TCP packets in a blocking manner so that the send queue doesn’t grow too large. Is there a mechanism for this in Mongoose’s networking library.
I figure that the solution is going to be putting the thread to sleep so that the networking thread can start emptying the send queue, but I don’t know how the tasks are being set in FreeRTOS within Mongoose OS.
Anyone tried something like this?