Skip to content

BrokenPipeError in network.fetch #127

@dyeazel

Description

@dyeazel

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 <module>
  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions