2

tl;dr: Using a DNS server on a local network causes socket.getaddrinfo() to experience an error:

OS Error: [Error 103] ECONNABORTED

Using an internet DNS server works.

Details: I have a very simple program which does a socket.getaddrinfo() call:

import socket

host = 'google.com'
port = 443
addr_info = socket.getaddrinfo(host, port)
print('addr_info:', addr_info)

The ESP8266 on which this runs (an ESP-12F) gets its IP address served by DHCP.

When the local DHCP server is set up to deliver an IP address block as follows, the code above works just fine:

IP address: 192.168.X.X
Router: 192.168.X.Y
DNS server: **8.8.8.8**

When the local DHCP server is set up to deliver this IP address block, the code above fails with the ECONNABORTED error:

IP address: 192.168.X.X
Router: 192.168.X.Y
DNS: **192.168.X.X**

(Note that, yes, the router is also the DNS server. It does recursive DNS, using the upstream DNS servers provider by my ISP. This DNS server setup works for all other cases)

I know the WiFi connection is up at the time this program is run, and has internet access.

I have done a network packet trace to see if the ESP8266 is sending any data. It does send data when the 8.8.8.8 DNS server is used; it does not send any data when the 192.168.X.X DNS server is used.

Basically, by all failure characteristics, this seems to be a problem in the Micropython socket module for the getaddrinfo class.

Has anyone else seen this problem? Or know how to delve further into the bowels of the Micropython beast to figure it out?

2
  • Well, minutes after posting this question, I found another post that gave me a clue. As it turns out--and I hadn't noticed until now--the ESP8266 comes up with AP mode set by default, so it creates an AP. Even though my code then sets up STA mode and it appears to work, when I turned off AP mode in boot.py before setting up the STA connection, the problem went away! Who knew? Commented Oct 27 at 19:00
  • Please delete your comment and instead post it as an answer. Commented Oct 27 at 22:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.