Open meeki007 opened 1 month ago
This is a limitation of lwip, the socket library that is used by Espressif devices (and RP2040 wifi devices, when it comes to that). Their source code .../lwip/src/api/netdb.c
states:
* Due to a limitation in dns_gethostbyname, only the first address of a
* host is returned.
* Also, service names are not supported (only port numbers)!
CircuitPython's implementation of getaddrinfo is prepared to return multiple addresses when you call socket.getaddrinfo
but the underlying library doesn't provide multiple addresses yet.
CircuitPython's implementation of getaddrinfo is prepared to return multiple addresses when you call
socket.getaddrinfo
but the underlying library doesn't provide multiple addresses yet.
Good to know! I'll keep my for loop that tires connecting the mqtt client to each address so when this is implemented its waiting to work.
CircuitPython version
Code/REPL
Behavior
individual_addressInfo: (2, 1, 0, '', ('172.67.39.47', 80))
Description
I can see the host has multiple A records and addresses for the site.
In python I get a List of all the ip addresses, A records, from the host.
Additional information
See documentation ---> https://docs.circuitpython.org/en/latest/shared-bindings/socketpool/#socketpool.SocketPool.getaddrinfo It says I should be getting a List of Tuples.
Why is this important .... to me.
I am migrating my code from micropython to circuitpython and I noticed that my MQTT messages were not going through from the test device. I then found out one of my servers in my High Availability MQTT cluster was down. I was expecting it to just round robin my List of Tuples from getaddrinfo. Whats the point of outputting a List of Tuples if the list only ever contains 1 value ???