Skip to content

DNS lookup fails with SocketException #1008

Closed
@jonmill

Description

@jonmill

Target name(s)

ESP32_REV0

Firmware version

1.8.0.6

Was working before? On which version?

N/A

Device capabilities

ESP32 (ESP32-D0WDQ6 (revision 1))
Features WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Flash size 4MB unknown from (manufacturer 0x216 device 0x16406)
PSRAM: not available
Crystal 40MHz

Description

I'm getting a SocketException during Dns.GetHostEntry that is traced to the NativeSocket::getaddrinfo call (call stack below). The DNS entry does exist and can be retrieved using this call in a normal .NET Core app.

++++ Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ++++
    ++++ Message: 
    ++++ System.Net.Sockets.NativeSocket::getaddrinfo [IP: 0000] ++++
    ++++ System.Net.Dns::GetHostEntry [IP: 0008] ++++
    ++++ Testing.Program::Main [IP: 013f] ++++
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.dll
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.dll

WiFi is connected with a valid IP and DateTime and the address being looked up is infrastructure.local. A .NET Core app can lookup the address fine, but not the ESP32. There is no trace of the request hitting the DNS server

bool connected = nanoFramework.Networking.WiFiNetworkHelper.ConnectDhcp(
                WIFI_NAME,
                WIFI_PWD,
                WiFiReconnectionKind.Automatic,
                requiresDateTime: true,
                wifiAdapter: 0);
            if (connected == false)
            {
                throw new InvalidOperationException("Could not connect to WiFi");
            }
            else
            {
                Console.WriteLine($"Current Time Post-Connect: {now.Month}/{now.Day}/{now.Year} {now.Hour}:{now.Minute}:{now.Second}");
            }

How to reproduce

  1. Have a DNS server (ex pihole) resolve a .local address as an A record to a local server
  2. Have an ESP32 attempt DNS resolve for the .local address

Expected behaviour

The DNS entry resolves to an IP address

Screenshots

No response

Aditional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions