micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

requests: requests.get() blocks infinitely

Open tacker66 opened this issue 1 year ago • 3 comments

I am trying to call requests.get(some_REST_API_call) on a Pico W (with v1.22.1) but this call blocks infinitely. Using a timeout or non-blocking mode (timeout=0) doesn't help. The call works with CPython and in Chrome and returns some small JSON.

When using self._cached = self.raw.recv(10000) instead of self._cached = self.raw.read() in requests/__init__.py (line 20) the call works fine.

So shouldn't this read() be replaced with a loop which tries to recv(num_bytes) until it read less than num_bytes and then stops?

Update: Tested this with a different kind of device (calling the ThingSpeak API with requests.post) and for that only read() works correctly. recv(num_bytes) yields no bytes.

tacker66 avatar Feb 08 '24 12:02 tacker66

Are you able to provide a URL that shows the issue? So that someone else can reproduce the problem.

dpgeorge avatar Feb 08 '24 23:02 dpgeorge

This happens when trying to call the local API of an APSystems EZ1 micro-inverter. Perhaps someone from Sonnenladen could help here. I raised an issue there.

tacker66 avatar Feb 09 '24 07:02 tacker66