goecharger / go-eController-API

API specification for go-eController
9 stars 1 forks source link

Rest API V2 Transfer-encoding: chunked #6

Open HeikoG67 opened 10 months ago

HeikoG67 commented 10 months ago

The current API response delivers result as Transfer-encoding: chunked. It is no problem using Pyhton V3.x request but in case using e.g. micropython version of request, it cannot handle chunked requests. So it is difficult to use a simple microcontroller based control setup. I am currently using a PI pico to continously get PV data from a Fenecon inverter and send it to my go-e charger to allow pv surplus charging. I found a way to get it working without request but it could be much simpler without Transfer-encoding: chunked.

0xFEEDC0DE64 commented 10 months ago

The ESP32 in the charger doesnt have enough heap space free to store the full http response in memory, therefore I implemented a 4kb chunked buffering while returning the response, there are no ways to change that!

could you setup your raspberry pi as a simple reverse proxy to the charger maybe?

mincequi commented 5 months ago

Hi @0xFEEDC0DE64 , indeed, these chunked transfers are troublesome for microcontrollers (and other incomplete http clients). I was also wondering, why the chunked header is default. Even for smaller messages than 4kb. Since i also get a chunked header for this filter: /api/status?filter=nrg,car

Is there anything you can do about this? My shelly devices do not send chunked data.

Thanks a lot!

Cheers.

peterpoetzi commented 5 months ago

Maybe we can introduce a GET parameter &nochunk that will disable this behavior and either give you the full response if it is below 4kB or an HTTP error response otherwise

mincequi commented 5 months ago

Yes, that sounds good. Or you just remove the chunked header when message buffer is below 4kB?