Error 500, continue
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Error 500, continue
Did you remove the MPY files that were in adafruit_portalbase/? If the network.mpy is there your network.py will be ignored.
- Saketaram
- Posts: 17
- Joined: Fri May 27, 2022 4:51 pm
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Error 500, continue
Can you post the full contents of your lib/ folders in CODE tags? Maybe there is another network library being pulled in?
I see you have been running CircuitPython 7.3.3. Do you mind trying 8.0.0-beta? If the behavior is the same the you can open an issue with the github repo.
https://circuitpython.org/board/matrixportal_m4/
I see you have been running CircuitPython 7.3.3. Do you mind trying 8.0.0-beta? If the behavior is the same the you can open an issue with the github repo.
https://circuitpython.org/board/matrixportal_m4/
- Saketaram
- Posts: 17
- Joined: Fri May 27, 2022 4:51 pm
Re: Error 500, continue
Hi Mikeyslar,
Thank you for helping me on this.
There is another network.py in .\lib\adafruit_matrixportal. It's a much smaller file than the one I modified.
I'm waiting for your feedback before upgrading to 8.0.0, if you don't see another thing we can try on the current setup.
Here is lib folder content.
Thank you for helping me on this.
There is another network.py in .\lib\adafruit_matrixportal. It's a much smaller file than the one I modified.
I'm waiting for your feedback before upgrading to 8.0.0, if you don't see another thing we can try on the current setup.
Here is lib folder content.
Code: Select all
C:\>dir f:\lib\* /ON /S
Volume in drive F is CIRCUITPY
Volume Serial Number is 2821-0000
Directory of f:\lib
14 Sep 2022 21:38 <DIR> .
14 Sep 2022 21:38 <DIR> ..
13 Sep 2022 21:27 <DIR> adafruit_bitmap_font
10 Sep 2022 08:30 62,092 adafruit_datetime.py
13 Sep 2022 21:27 <DIR> adafruit_display_text
10 Sep 2022 08:30 1,366 adafruit_fakerequests.py
10 Sep 2022 08:30 <DIR> adafruit_io
13 Sep 2022 21:27 <DIR> adafruit_matrixportal
10 Sep 2022 08:30 <DIR> adafruit_minimqtt
10 Sep 2022 08:30 <DIR> adafruit_portalbase
10 Sep 2022 08:30 5,157 neopixel.py
3 File(s) 68,615 bytes
Directory of f:\lib\adafruit_bitmap_font
14 Sep 2022 21:38 <DIR> .
14 Sep 2022 21:38 <DIR> ..
10 Sep 2022 08:30 0 __init__.py
10 Sep 2022 08:30 8,500 bdf.py
10 Sep 2022 08:30 1,686 bitmap_font.py
10 Sep 2022 08:30 1,471 glyph_cache.py
10 Sep 2022 08:30 14,095 pcf.py
10 Sep 2022 08:30 2,210 ttf.py
6 File(s) 27,962 bytes
Directory of f:\lib\adafruit_display_text
14 Sep 2022 21:38 <DIR> .
14 Sep 2022 21:38 <DIR> ..
10 Sep 2022 08:30 17,730 __init__.py
10 Sep 2022 08:30 21,852 bitmap_label.py
10 Sep 2022 08:30 17,123 label.py
10 Sep 2022 08:30 4,814 scrolling_label.py
4 File(s) 61,519 bytes
Directory of f:\lib\adafruit_matrixportal
14 Sep 2022 21:38 <DIR> .
14 Sep 2022 21:38 <DIR> ..
10 Sep 2022 08:30 0 __init__.py
10 Sep 2022 08:30 2,645 graphics.py
10 Sep 2022 08:30 7,934 matrix.py
10 Sep 2022 08:30 10,717 matrixportal.py
10 Sep 2022 08:30 2,830 network.py
5 File(s) 24,126 bytes
Directory of f:\lib\adafruit_portalbase
14 Sep 2022 21:43 <DIR> .
14 Sep 2022 21:43 <DIR> ..
10 Sep 2022 08:30 21,419 __init__.py
10 Sep 2022 08:30 5,910 graphics.py
27 Sep 2022 11:22 24,829 network.py
10 Sep 2022 08:30 3,573 wifi_coprocessor.py
10 Sep 2022 08:30 2,721 wifi_esp32s2.py
5 File(s) 58,452 bytes
Directory of f:\lib\adafruit_minimqtt
14 Sep 2022 21:48 <DIR> .
14 Sep 2022 21:48 <DIR> ..
10 Sep 2022 08:30 0 __init__.py
10 Sep 2022 08:30 40,499 adafruit_minimqtt.py
10 Sep 2022 08:30 3,336 matcher.py
3 File(s) 43,835 bytes
Directory of f:\lib\adafruit_io
14 Sep 2022 21:47 <DIR> .
14 Sep 2022 21:47 <DIR> ..
10 Sep 2022 08:30 0 __init__.py
10 Sep 2022 08:30 29,023 adafruit_io.py
10 Sep 2022 08:30 888 adafruit_io_errors.py
3 File(s) 29,911 bytes
Total Files Listed:
29 File(s) 314,420 bytes
20 Dir(s) 988,160 bytes free
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Error 500, continue
The adafruit_matrixportal/network.py appears to just load the same adafruit_portalbase/network.py
Please try the current 8.x beta and we can see how if that makes reconnect / retry any easier.
Please try the current 8.x beta and we can see how if that makes reconnect / retry any easier.
- Saketaram
- Posts: 17
- Joined: Fri May 27, 2022 4:51 pm
Re: Error 500, continue
Hi Mikeyslar,
I updated to 8.x beta version.
Here is the log:
and here is my network.py on that section
It seems to not read my network.py if I refer to the log when the cloud replies with a 200.
I expect the log to be
"Reply is OK. Yes Ok!"
And we still get
"Reply is OK!" which is the standard library.
Do you have an idea?
Thanks
I updated to 8.x beta version.
Here is the log:
Code: Select all
]0;🐍REPL | 8.0.0-beta.1\
Adafruit CircuitPython 8.0.0-beta.1 on 2022-10-01; Adafruit Matrix Portal M4 with samd51j19
>>>
]0;🐍Done | 8.0.0-beta.1\soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
]0;🐍code.py | 8.0.0-beta.1\Connecting to AP Ayotee
Getting time for timezone Europe/Paris
Now: 21 : 51
Retrieving data...Reply is OK!
ZUMO 22:05 Saint-Germain-en-Laye
ZUMO 22:21 Saint-Germain-en-Laye
ZUMO 22:32 Saint-Germain-en-Laye
ZUMO 22:44 Saint-Germain-en-Laye
ZUMO 22:59 Saint-Germain-en-Laye
QIKI 21:53 Marne-la-Vallee Chessy
QIKI 22:05 Marne-la-Vallee Chessy
QIKI 22:21 Marne-la-Vallee Chessy
14 30 14 30
Getting time for timezone Europe/Paris
Now: 21 : 52
Retrieving data...Reply is OK!
ZUMO 22:04 Saint-Germain-en-Laye
ZUMO 22:21 Saint-Germain-en-Laye
ZUMO 22:32 Saint-Germain-en-Laye
ZUMO 22:45 Saint-Germain-en-Laye
ZUMO 22:59 Saint-Germain-en-Laye
QIKI 22:05 Marne-la-Vallee Chessy
QIKI 22:21 Marne-la-Vallee Chessy
12 29 13 29
Getting time for timezone Europe/Paris
Now: 21 : 53
Retrieving data...Traceback (most recent call last):
File "code.py", line 115, in <module>
File "code.py", line 25, in next_trains
File "adafruit_portalbase/network.py", line 599, in fetch_data
File "adafruit_portalbase/network.py", line 610, in _parse_data
File "adafruit_portalbase/network.py", line 564, in check_response
HttpError: Code 500: Internal Server Error
]0;🐍564@adafruit_portalbase/network.py HttpError | 8.0.0-beta.1\
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
]0;🐍code.py | 8.0.0-beta.1\Connecting to AP Ayotee
Getting time for timezone Europe/Paris
Now: 21 : 57
Retrieving data...Reply is OK!
ZUMO 22:04 Saint-Germain-en-Laye
ZUMO 22:20 Saint-Germain-en-Laye
ZUMO 22:33 Saint-Germain-en-Laye
ZUMO 22:44 Saint-Germain-en-Laye
ZUMO 22:59 Saint-Germain-en-Laye
ZUMO 23:14 Saint-Germain-en-Laye
QIKI 22:05 Marne-la-Vallee Chessy
QIKI 22:21 Marne-la-Vallee Chessy
7 23 8 24
Getting time for timezone Europe/Paris
Now: 21 : 58
Retrieving data...Traceback (most recent call last):
File "code.py", line 115, in <module>
File "code.py", line 25, in next_trains
File "adafruit_portalbase/network.py", line 599, in fetch_data
File "adafruit_portalbase/network.py", line 610, in _parse_data
File "adafruit_portalbase/network.py", line 564, in check_response
HttpError: Code 500: Internal Server Error
]0;🐍564@adafruit_portalbase/network.py HttpError | 8.0.0-beta.1\
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
]0;🐍REPL | 8.0.0-beta.1\
Adafruit CircuitPython 8.0.0-beta.1 on 2022-10-01; Adafruit Matrix Portal M4 with samd51j19
Code: Select all
def check_response(self, response):
"""
Check the response object status code, change the lights, and return content type
:param response: The response object from a network call
"""
headers = self._get_headers(response)
if self._debug:
print("Headers:", headers)
if response.status_code == 200:
print("Reply is OK. Yes Ok!")
self.neo_status(STATUS_DATA_RECEIVED) # green = got data
content_type = self._detect_content_type(headers)
else:
print("HttpError again, yes yes")
if self._debug:
if "content-length" in headers:
print("Content-Length: {}".format(int(headers["content-length"])))
if "date" in headers:
print("Date: {}".format(headers["date"]))
print("HttpError again, yes")
self.neo_status((100, 0, 0)) # red = http error
print("HttpError again")
time.sleep(15)
break;
# raise HttpError(
# "Code {}: {}".format(
# response.status_code, response.reason.decode("utf-8")
# )
# )
return content_type
@staticmethod
def _get_headers(response):
headers = {}
for title, content in response.headers.items():
headers[title.lower()] = content
gc.collect()
return headers
I expect the log to be
"Reply is OK. Yes Ok!"
And we still get
"Reply is OK!" which is the standard library.
Do you have an idea?
Thanks
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Error 500, continue
Thank you for trying the 8.x upgrade.
Were you also able to see how it handled disconnects or if it was anymore stable? I see that 8.x Beta 1 was released today.
The adafruit_portalbase is being frozen into the CircuitPython image you are downloading for the Matrix Portal. That means your library is not being used due to it already being bundled with the build.
https://github.com/adafruit/circuitpython/issues/6461
https://docs.circuitpython.org/en/lates ... atrix.html
Were you also able to see how it handled disconnects or if it was anymore stable? I see that 8.x Beta 1 was released today.
The adafruit_portalbase is being frozen into the CircuitPython image you are downloading for the Matrix Portal. That means your library is not being used due to it already being bundled with the build.
https://github.com/adafruit/circuitpython/issues/6461
https://docs.circuitpython.org/en/lates ... atrix.html
- Saketaram
- Posts: 17
- Joined: Fri May 27, 2022 4:51 pm
Re: Error 500, continue
Hi Mickeyslar,
It exits the code on error once there is a 500 and stops like on the previous version.
How can I unfreeze/unbundle the adafruit_portalbase to use mine? Reduce the imports at the beginning?
Thanks in advance
It exits the code on error once there is a 500 and stops like on the previous version.
How can I unfreeze/unbundle the adafruit_portalbase to use mine? Reduce the imports at the beginning?
Thanks in advance
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Error 500, continue
Good question about unbundling or removing the frozen libs. A few options come to mind.
1) There might be a way to unload the frozen modules so you can re-import your own. I think something like the following.
2) Try to import your local module with a full path name using:
3) Rebuild the CircuitPython UF2 image you are using with the frozen modules either modified to your liking or removed.
https://learn.adafruit.com/building-cir ... en-modules
1) There might be a way to unload the frozen modules so you can re-import your own. I think something like the following.
Code: Select all
del sys.modules[mod_name]
Code: Select all
import /lib/adafruit_portalbase/network.py
https://learn.adafruit.com/building-cir ... en-modules
- danhalbert
- Posts: 4654
- Joined: Tue Aug 08, 2017 12:37 pm
Re: Error 500, continue
If you put the replacement module in the top level of CIRCUITPY instead of in lib/, it will override the frozen library. sys.path is
so frozen libraries take preference over libraries in /lib, but not in / .
Note that .frozen is a fake directory. There is no such actual directory.
Code: Select all
['', '/', '.frozen', '/lib']
Note that .frozen is a fake directory. There is no such actual directory.
Please be positive and constructive with your questions and comments.