adafruit / adafruit/Adafruit_CircuitPython_Requests

BrokenPipeError in network.fetch

Open
#127 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
49
Forks
39
PR merge metrics
No merged PRs in 30d

Description

I'm getting an error with network.fetch on an Adafruit Matrix Portal M4.

Error details:

```
Traceback (most recent call last):
File "adafruit_requests.py", line 527, in _get_socket
File "adafruit_requests.py", line 757, in connect
File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 75, in connect
File "adafruit_esp32spi/adafruit_esp32spi.py", line 806, in socket_connect
File "adafruit_esp32spi/adafruit_esp32spi.py", line 702, in socket_open
File "adafruit_esp32spi/adafruit_esp32spi.py", line 332, in _send_command_get_response
File "adafruit_esp32spi/adafruit_esp32spi.py", line 302, in _wait_response_cmd
File "adafruit_esp32spi/adafruit_esp32spi.py", line 284, in _check_data
BrokenPipeError: Expected 01 but got 00

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "code.py", line 29, in
File "adafruit_portalbase/network.py", line 518, in fetch
File "adafruit_requests.py", line 816, in get
File "adafruit_requests.py", line 661, in request
File "adafruit_requests.py", line 508, in _get_socket
RuntimeError: Sending request failed
```

sample code:

```
import board
import terminalio
from adafruit_matrixportal.network import Network

# Get wifi details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise

network = Network(status_neopixel=board.NEOPIXEL, debug=False)

if not network.is_connected:
# connect to the network defined in secrets.py
print("connecting")
network.connect()

# connect to a test page to show the network is working
print("fetch test")
response = network.fetch_data("https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400")
print("")
print("-" * 40)
print(response)
print("-" * 40)

# connect to another page that fails
print("fetch zones")
response = network.fetch("https://www.yeazel2.net/")
print()
print("-" * 40)
print(response)
print("-" * 40)
```

if you try the URL ( https://www.yeazel2.net/ ) in a browser you'll see that it works.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with the supplied Matrix Portal M4 sample, comparing the successful fetch_data call with the failing network.fetch URL. Start by reading adafruit_requests.py around _get_socket, connect, and request, then follow the traceback into adafruit_esp32spi_socket.py and adafruit_esp32spi.py. Done means the reported URL no longer produces RuntimeError: Sending request failed, with the existing behavior preserved for the working request.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.