Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BrokenPipeError in network.fetch #127

Open
dyeazel opened this issue Feb 25, 2023 · 5 comments
Open

BrokenPipeError in network.fetch #127

dyeazel opened this issue Feb 25, 2023 · 5 comments

Comments

@dyeazel
Copy link

dyeazel commented Feb 25, 2023

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.

@alienryes
Copy link

alienryes commented Apr 9, 2024

I have the same issue with very similar code but a different API url: https://opensky-network.org/api/states/all?lamin=-2.0609&lomin=51.4238&lamax=-1.9510&lomax=51.4580

Retrieving data...Traceback (most recent call last):
File "adafruit_connection_manager.py", line 271, in get_socket
File "adafruit_connection_manager.py", line 63, in connect
File "adafruit_esp32spi/adafruit_esp32spi_socket.py", line 77, in connect
File "adafruit_esp32spi/adafruit_esp32spi.py", line 819, in socket_connect
File "adafruit_esp32spi/adafruit_esp32spi.py", line 715, in socket_open
File "adafruit_esp32spi/adafruit_esp32spi.py", line 341, in _send_command_get_response
File "adafruit_esp32spi/adafruit_esp32spi.py", line 311, in _wait_response_cmd
File "adafruit_esp32spi/adafruit_esp32spi.py", line 293, 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 26, in
File "adafruit_portalbase/network.py", line 645, in fetch_data
File "adafruit_portalbase/network.py", line 563, in fetch
File "adafruit_requests.py", line 591, in get
File "adafruit_requests.py", line 525, in request
File "adafruit_connection_manager.py", line 282, in get_socket
RuntimeError: Error connecting socket: Expected 01 but got 00

@feduks
Copy link

feduks commented May 11, 2024

Both are using Let's Encrypt, and me too. I' am checking how to add this CA validate or ignore SSL verification. Keep in touch!

@anecdata
Copy link
Member

You may need to update the NINA firmware on the ESP32 for an updated certificate bundle:
https://learn.adafruit.com/upgrading-esp32-firmware/overview

@feduks
Copy link

feduks commented May 12, 2024

Thanks @anecdata !!! First Upload Passthrough Code and after Download NINA Firmware. It´s important the first step.

@dhalbert
Copy link
Contributor

Yes, updated NINA-FW has new root certificates: adafruit/nina-fw#57. Note that there is still a problem with at least some elliptical cryptography cert chains: adafruit/nina-fw#58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@dyeazel @dhalbert @feduks @anecdata @alienryes and others