-
Notifications
You must be signed in to change notification settings - Fork 5
In my environment sys.implementation was a namespace instead of a list #20
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
Comments
What environment are you using? |
$ cat /etc/os-release |
And what hardware are you using? Would like to match to see which flow it should take (if it can take the native SSL or not) |
Luxkfox Pico Max. |
Cool. Will find the best way to validate. It doesn't list the Ethernet chip, it's a WIZnet5k? |
thank you.
Yes WIZnet5k |
@nopnop2002 when you have a moment, can you try: # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import board
import busio
import digitalio
import adafruit_connection_manager
import adafruit_requests
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
print("Wiznet5k WebClient Test")
spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
# For Adafruit Ethernet FeatherWing
cs = digitalio.DigitalInOut(board.D10)
# For Particle Ethernet FeatherWing
# cs = digitalio.DigitalInOut(board.D5)
# Initialize ethernet interface with DHCP
eth = WIZNET5K(spi_bus, cs)
print("-------------------------------------")
print("Test 1: does it work without ssl")
print("-------------------------------------")
pool = adafruit_connection_manager.get_radio_socketpool(eth)
requests = adafruit_requests.Session(pool)
HTTP_URL = "http://wifitest.adafruit.com/testwifi/index.html"
print(f"Fetching via http: {HTTP_URL}")
with requests.get(HTTP_URL) as response:
print(response.text)
adafruit_connection_manager.connection_manager_close_all(release_references=True)
print("-------------------------------------")
print("Test 2: does it work with ssl")
print("-------------------------------------")
import ssl
pool = adafruit_connection_manager.get_radio_socketpool(eth)
ssl_context = ssl.create_default_context()
requests = adafruit_requests.Session(pool, ssl_context)
HTTPS_URL = "https://www.adafruit.com/api/quotes.php"
print(f"Fetching via https: {HTTPS_URL}")
with requests.get(HTTPS_URL) as response:
print(response.text)
|
This is the result of trying your code.
this example work fine.
In both cases, the following parts are commented out.
|
My bad, I forgot getting the pool runs through the same code. Can you change: pool = adafruit_connection_manager.get_radio_socketpool(eth) To import adafruit_wiznet5k.adafruit_wiznet5k_socketpool as socketpool
pool = socketpool.SocketPool(eth) |
I changed it as follows.
This is the result.
|
I tried changing it like this.
Fetch with http and https.
regular http request is ok.
ssl import is successful
I can't understand.
|
So here is the error for SSL:
That's the built in SSL module trying to get the socket type from the WIZNet5k socket and You could add the following to @_check_socket_closed
def getsockopt(self, level, opt):
if level == SocketPool.SOL_SOCKET and opt == SocketPool.SOCK_STREAM:
return self._sock_type
raise OSError And see if that gets you any further |
adafruit_wiznet5k_socketpool.py has 2 class. class SocketPool: class Socket: Which should I add this to?
I added this to Socket class.
|
Can you print |
|
Ahh, by mistake, since it's passing in
Which isn't Just try always returning |
I'm not native. |
Sorry about that:
|
I changed it like this.
I'm going to work now, so my reply will be delayed. |
Okay. So to support CPython SSL via the WIZNet5k will take some work. Are you needing SSL? |
I don't need it right away. Please spend a lot of time working on it. |
Okay, I'll open up a PR here to handle this case, and treat it like SSL isn't supported. If willing, can you please open a new issue here: https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k for supporting CPython SSL? |
That's fine.
Let's get back to this problem.
|
@nopnop2002 can you try the code from here: #21? No SSL, but will work with HTTP requests. |
I tested your code. There will be no error. My implementation_name=cpython
I added print.
You may need to change it for cpython , micropython and circuitpython environments.
|
This issue will be closed once the your draft code is merged. The SSL issue will be carried over into another issue. Thank you for your efforts. |
Fixed with #21 |
In my environment sys.implementation was a namespace instead of a list.
So this example will be an error.
I think you need to determine if sys.implementation is a list.
https://github.com/adafruit/Adafruit_CircuitPython_ConnectionManager/blob/main/adafruit_connection_manager.py#L152
The text was updated successfully, but these errors were encountered: