QUERY · ISSUE
WiPy/CC3200: usocket.socket.settimeout() not working for socket.getaddrinfo()
In issue https://github.com/micropython/micropython/issues/2402 a solution was proposed to make socket.settimeout() working for socket.connect(). It seems to work well.
However it does not work for socket.getaddrinfo() as there seems to be fixed timeout of 19s.
import socket
import ssl
import time
def test():
start = time.time()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC)
s = ssl.wrap_socket(s, cert_reqs=ssl.CERT_REQUIRED, ca_certs='/flash/cert/ca.pem')
s.settimeout(3)
try:
print(socket.getaddrinfo("www.google.com", 443)[0][-1])
except Exception as e:
print(e)
finish = time.time()
print(finish - start)
s.close()
EDIT: Looking at the code once again it is obvious that calling settimeout() method of socket instance cannot affect timeout of socket.getaddrinfo(). Anyway is there any way how to modify timeout of this method?
CANDIDATE · ISSUE
Unix (only) socket.getaddrinfo() fails
This would appear to be a regression. Built from today's source.
Unix:
$ upython
MicroPython v1.8.7-1080-g394c536-dirty on 2017-08-20; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import usocket as socket
>>> socket.getaddrinfo('iot.eclipse.org', 1883)[0][-1]
bytearray(b'\x02\x00\x07[\xc6)\x1e\xf1\x00\x00\x00\x00\x00\x00\x00\x00')
>>>
ESP8266:
MicroPython v1.8.7-1080-g394c536-dirty on 2017-08-20; ESP module with ESP8266
Type "help()" for more information.
>>>
>>> ipm open,type:2 0
>>> import usocket as socket
>>> socket.getaddrinfo('iot.eclipse.org', 1883)[0][-1]
('198.41.30.241', 1883)
>>>