1 month, 1 week ago.

mbed OS - http_mbed - Cannot http PUT payload larger then 1000 bytes?

I have been uploading JPG images (100K+) using HTTP PUT with older mbed using httpclient and cell modem

With Mbed OS and http_mbed and same modem but using generic PPP/LWIP it fails immediately after about 1400 bytes. I have lots of RAM and tried changing the send function to small blocks but no success.

Thought it might be related to LWIP heap size which may mean it is impossible to send large payloads using generic PPP/LWIP?

I've certainly been able to *download* large files with mbed-http... I'll see if I can reproduce. Does it crash or does sending fail?

posted by Jan Jongboom 15 Dec 2017

It just returned with a byte count of only 1028 bytes of a 20k jpeg buffer. No other error codes. When I turn on AT debugging it does not get to that point for some reason. I am sending this to AWS S3.When I send small buffer it works with no errors.

posted by Len Metcalfe 15 Dec 2017

It turns out that Uartserial returns failed when txbuf is full causing mbed-http to fail as an error terminating transmission of large payloads. Needs a callback similar to receiving code for a large responses so that large payloads can be sent.

posted by Len Metcalfe 19 Dec 2017

Hi Len, interesting... I would think this is a bug in the underlying driver. Created bug report for PPPInterface here.

posted by Jan Jongboom 02 Jan 2018

@Len, according to this comment the behavior has changed in Mbed OS 5.7. Can you test this against latest version of Mbed OS?

posted by Jan Jongboom 03 Jan 2018
Comment on this question

1 Answer

2 weeks, 2 days ago.

The underlying issue has now been fixed in Mbed OS 5.7. For earlier versions of Mbed OS a fix has been pushed to mbed-http (here).

I can now successfully send very large buffers to httpbin.

Update: Mbed-http now supports chunked requests, so you can stream large requests without loading them into memory. See the mbed-http readme.

Thanks for doing this. Not sure what the fix is in 5.7 but one of the other issues is that build is pushing the payload on the heap which does not work well with 150K files in memory/flash so I just patched it so that it builds the header and sends in blocks similar to 5.6 fix from the source buffer. I will take a look at 5.7. It seems if a file was being sent from flash you would want a callback to fetch next block so that little RAM is used.

posted by Len Metcalfe 03 Jan 2018

Re, heap, yes, correct. Note that Mbed OS 5.7 does not fix that either, just the underlying issue with the socket not doing buffering by itself. A quick way of fixing that would be to take the send function of HttpRequest and copying it over to your application, then replacing the set buffer by one where you read a block from flash instead... Would still get you most benefits, such as response parsing, and request building. Streaming this would change the way that request building is done, so that requires some more work on the API design. Will add it to my backlog.

posted by Jan Jongboom 03 Jan 2018

I've pushed a fix to mbed-http that supports chunked requests. That should fix your issue.

posted by Jan Jongboom 11 Jan 2018

To post an answer, please log in.