Closed valenzmanu closed 3 years ago
@junhuanchen
Ah, sorry, this socket.getAddrInfo is implemented on the AT network card, which means it needs to support HTTPS on the network card, not the built-in function of K210.
Maybe you may configure or burn the firmware for ES8285/ESP32 that supports HTTPS parsing.
Such as
try:
err = 0
while 1:
try:
self._socketAddr = socket.getaddrinfo(host, port)[0][-1]
break
except Exception:
err += 1
if err > 5:
raise Exception("get ip failed!")
#cli = socket.socket()
cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
cli.settimeout(self.ConnTimeoutSec)
cli.connect(self._socketAddr)
except:
raise Exception('Error to connect to %s:%s' % (host, port))
Thanks,
I'm not sure what firmware to burn into the ESP32 or how to do it. Should I use the USB-C port? I see the ESP32 is connected to the CH552 which is connected to the USB port. If so, what software do you recommend? I've been using Kflash ever since I started using the Maixduino, will it work to burn ESP32 firmware?
Regarding your code, I don't quite understand where should it be at? What Class self._socketAddr
refers to?
I'm not sure what you're using right now, but you can try burning AT firmware for ESP8266 and try AT parsing HTTPS to get IP. It's much easier for you
Not all HTTPS gets IP
This is a bug that relies on an external network.
I'm trying to make a HTTPS request, so I'm using the firmware in https://github.com/sipeed/MaixPy/tree/develop since the
ussl
module is needed.When I try to connect using the hostname I get
[Errno 22] EINVAL
insocket.getaddrinfo(HOST, PORT)[0][-1]
. I tried changing hostname to the public IP (using a service like this: https://www.cdmon.com/es/conversor-host-ip) and I no longer got this error, however I think this is a problem since the public IP might change at any given time.Here is a snippet of my code (I'm using a maixduino, and it was already connected to a wifi network):