micropython / micropython/micropython-lib

Urequests can't parse response data

Open
#364 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
1.1k
Avg merge
7d 6h
Merged PRs (30d)
3

Description

I'm trying to talk to my nanoleaf over my ESP8266 board. I'm using micropython and the urequests library I installed using upip.install('urequests').

urequests.get works and I can parse the response from something like: https://jsonplaceholder.typicode.com/posts/1

However when I try to parse the response from my nanoleaf with reponse.text the call just stops. I'm testing it over the UART REPL and it just does nothing until I ctrl+c then get a keyboard interrupt:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "urequests.py", line 57, in text
  File "urequests.py", line 49, in content
KeyboardInterrupt:

Using normal python on my x86 and requests with the same line works.

I'm using:

response = urequests.get(url)
response.text

Curl returns this from the nanoleaf:

{"on":{"value":true},"brightness":{"value":76,"max":100,"min":0},"hue":{"value":28,"max":360,"min":0},"sat":{"value":66,"max":100,"min":0},"ct":{"value":2700,"max":6500,"min":1200},"colorMode":"effect"}

Is that a memory issue? I'm not even trying to get the json, just the text result.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with urequests.py at the content and text entry points cited in the traceback, then reproduce response.text using the Nanoleaf response and the working JSONPlaceholder response. Determine why reading the Nanoleaf response does not return; the issue is resolved when the response can be read successfully without a keyboard interrupt.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.