Matrix Portal network/requests Errors

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Matrix Portal network/requests Errors

Post by Powderjockey »

I'm running https://learn.adafruit.com/weather-display-matrix and every so often the script locks up and the display freezes. Sometimes a couple of times a day or sometimes it will go for days before this happens.

Any idea what is causing this and how to correct it?

Code: Select all

Retrieving data...Traceback (most recent call last):
  File "code.py", line 99, in <module>
  File "code.py", line 93, in <module>
  File "adafruit_portalbase/network.py", line 548, in fetch_data
  File "adafruit_portalbase/network.py", line 467, in fetch
  File "adafruit_requests.py", line 684, in get
  File "adafruit_requests.py", line 586, in request
OutOfRetries: Repeated socket failures

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Matrix Portal network/requests Errors

Post by mikeysklar »

@Powderjocket,

It looks like there have been signicant changes to the codebase you are erroring out on. The repeated socket failures are going through the adafruit_portalbase CircuitPython library. Can you make sure all your CircuitPython libraries are up to date. This is the latest on the repo you can read about. I would install using the libraries link at the bottom.

https://github.com/adafruit/Adafruit_Ci ... PortalBase

Just make sure your running CircuitPython 6.2 and your libs are at 20210506 or better.

https://circuitpython.org/libraries

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: Matrix Portal network/requests Errors

Post by Powderjockey »

Thanks for the pointers. I have replaced all of the libraries with ones from 21-05-11 on 6.2.0 UF2.

I'll monitor and see what happens.

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: Matrix Portal network/requests Errors

Post by Powderjockey »

Had press the reset on the board twice today so far.

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: Matrix Portal network/requests Errors

Post by Powderjockey »

Problems with lock up persist.

Code: Select all

Retrieving data...Traceback (most recent call last):
  File "code.py", line 93, in <module>
  File "adafruit_portalbase/network.py", line 548, in fetch_data
  File "adafruit_portalbase/network.py", line 467, in fetch
  File "adafruit_requests.py", line 684, in get
  File "adafruit_requests.py", line 586, in request
OutOfRetries: Repeated socket failures

Code done running.
I've tried 6.3 stable with the updated libraries (21-06-25) and still problems. So I decided to give version 7.0 alpha 3 a go,know it is not stable, but there is no difference.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Matrix Portal network/requests Errors

Post by mikeysklar »

Are you keeping the libraries bundle version matched up with the 6.x and 7.x CircuitPython releases? eg. We do not want you to try and use a 6.x library with a 7.x CircuitPython release and vice-versa.

Looking at the source code for adafruit_requests.py I'm wondering if the timeout option would help.

Code: Select all

        # We may fail to send the request if the socket we got is closed already. So, try a second
        # time in that case.
        retry_count = 0
        while retry_count < 2:
            retry_count += 1
            socket = self._get_socket(host, port, proto, timeout=timeout)
            ok = True
            try:
                self._send_request(socket, host, method, path, headers, data, json)
            except (_SendFailed, OSError):
                ok = False
            if ok:
                # Read the H of "HTTP/1.1" to make sure the socket is alive. send can appear to work
                # even when the socket is closed.
                if hasattr(socket, "recv"):
                    result = socket.recv(1)
                else:
                    result = bytearray(1)
                    try:
                        socket.recv_into(result)
                    except OSError:
                        pass
                if result == b"H":
                    # Things seem to be ok so break with socket set.
                    break
            self._close_socket(socket)
            socket = None

        if not socket:
            raise OutOfRetries("Repeated socket failures")
A final option to consider is updating the esp32 firmware on the MatrixPortal. We have a guide for that.

https://learn.adafruit.com/upgrading-es ... -one-board

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: Matrix Portal network/requests Errors

Post by Powderjockey »

Thanks for the reply Mike, no mix up with the 6.0 and 7.0 libraries.

I'll give the timeout a go and install the newest .bin file for the esp32. This is the NINA_Wxxxx.x.x.x.bin? This board has the SAMD on it.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Matrix Portal network/requests Errors

Post by mikeysklar »

The MatrixPortal uses the ESP32 just for WiFi. We have a UF2 image that you should be able to drop in place for the upgrade based on the previous guide link I sent. Here is the direct link to the UF2 image.

https://cdn-learn.adafruit.com/assets/a ... ssthru.UF2

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: Matrix Portal network/requests Errors

Post by Powderjockey »

Is it possible to place a static IP Address into the MatrixPortal so that it grabs the same IP Address every time? I think the problem I'm having in this thread is my network and see this type of drop with the PyPortal as well.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Matrix Portal network/requests Errors

Post by mikeysklar »

I don't see any option in the esp32spi library you are using that will allow for setting the IP address to static.

https://circuitpython.readthedocs.io/pr ... t/api.html

What you could do is determine the mac address of your esp32s2 device using the above library and set your home access point to always hand out the same IP to that mac address.

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: Matrix Portal network/requests Errors

Post by Powderjockey »

I am still getting these errors on the MatrixPortal using CP 6.3.0. They happen about once every 2 or 3 days. I was using CP 7.0.0, but the same problem happened once or twice a day.

Code: Select all

Getting time from internet!
Getting time for timezone America/Edmonton
Traceback (most recent call last):
  File "code.py", line 88, in <module>
  File "code.py", line 84, in <module>
  File "adafruit_portalbase/network.py", line 231, in get_local_time
  File "adafruit_portalbase/network.py", line 214, in get_strftime
  File "adafruit_portalbase/network.py", line 200, in get_strftime
  File "adafruit_requests.py", line 684, in get
  File "adafruit_requests.py", line 586, in request
OutOfRetries: Repeated socket failures

Code done running.
Any thoughts?

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Matrix Portal network/requests Errors

Post by mikeysklar »

@Powderjocky,

There is a suggestion in this closed issue from the PortalBase library github repo.

If your demo is using this code:

Code: Select all

print("Connecting to AP...")
while not esp.is_connected:
    try:
        esp.connect_AP(secrets["ssid"], secrets["password"])
    except RuntimeError as e:
        print("could not connect to AP, retrying: ", e)
        continue
print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi)
Try replacing with this:

Code: Select all

pyportal.network.connect()
https://github.com/adafruit/Adafruit_Ci ... /issues/24

User avatar
Powderjockey
 
Posts: 189
Joined: Fri Mar 31, 2017 10:14 pm

Re: Matrix Portal network/requests Errors

Post by Powderjockey »

thanks for the tip. Unfortunately, neither of the scripts I'm using on a couple of different devices have your suggestion.

The replace seems much simpler.

Is it better to go to Github to look for solutions and post these type of problems.

Scott

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Matrix Portal network/requests Errors

Post by mikeysklar »

The forums are focused on getting people going with the necessary hardware and software setup. If there is a possible bug with CircuitPython or a library we often recommend going to the github repo and opening an issue.

The closest error I've seen to yours is from the github repo Adafruit_CircuitPython_Requests, but it turned out to be a routing issue on the users side.

https://github.com/adafruit/Adafruit_Ci ... /issues/79

You could open an issue on this repo. If possible provideminimum repeatable example code.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”