Large packet transmit

Hi. My goal is to send packets with Mongoose OS on an ESP8266 that are larger than the available memory.

It appears to me that the Mongoose OS API is structured in such a way that you must fit an entire packet (HTTPS in my case) in memory in order to send it. In our application, multiple messages are not an option, so I need the means of providing data to the system in a way that it will transmit partial data until the packet is complete. The data to be sent is from a larger external memory.

Is there a way to do so in the API, and I just missed it? Can I somehow go straight to the Mongoose API for providing partial data?

Searches in this forum for “send large packet” show one topic, but that author was able to divide the data into multiple packets.

Thanks for any help,
Aric.

Here is the doc how to send just file from fs with mg_http_serve_file - https://cesanta.com/docs/http/api-server.html

static void ev_handler(struct mg_connection nc, int ev, void ev_data) {
  switch (ev) {
    case MG_EV_HTTP_REQUEST: {
      struct http_message hm = (struct http_message ) ev_data;
      mg_http_serve_file(nc, hm, "file.txt",
                         mg_mk_str("text/plain"), mg_mk_str(""));
      break;
    }
    ...
  }
}

If you using mjs you can eval this function with ffi.

There is another page in docs with mg_send_response_line for webserver - https://mongoose-os.com/docs/mongoose-os/api/net/http-server.md

For client there is example with fwrite of http_message * struct: https://cesanta.com/docs/http/client-example.html

Thanks, Asondo. I will take a look at those. I did fail to say originally that this is an HTTPS client application. Saving to a file is not an option for us due to very long term flash memory issues, but I’ll look to see how it is done. The principle is probably the same.

Update: The file upload does multipart transfers, which means each part of a file is sent as a separate packet. So that is not sufficient for my needs. The fwrite() in the client example is just to print a received message body to stdout rather than writing to the packet stream.

So I am still looking for a solution.

Do you really need to send everything in a single packet? Or do you really just want to open a socket connection and then close the connection when the “large packet” is complete?

Hi, majorninth.

It has to be in a single HTTPS put. I don’t think I can close the socket when the packet is complete because we need to get a response.

This is for an AWS S3 upload application. Suppose we have data that is 1 MiB in length. We cannot use S3 multipart upload because it has a minimum chunk size of 5 MiB. But we cannot use Mongoose/Mongoose OS as I understand it so far because you cannot fit a 1 MiB packet in ESP8266 memory. Seems like a fundamental problem in Mongoose’s packet model.

By when the packet is complete I mean when the HTML response from the last chunk sent is successful and you have no more data to send.