DNS Issue



  • I am having an issue when using a fixed IP address.
    Each time I restart the device I get this error when connecting to a cloud server:

    { Error: DNS server returned general failure (at getaddrinfo)
        at [anon] internal code: 'ESERVFAIL', errno: 3, syscall: 'getaddrinfo' }
    

    If I upload new settings and change the DNS it works until next restart.

    node_modules/.bin/lowsync settings set eth.enabled=true eth.dhcp=static eth.static_ip=172.20.51.96 eth.static_net=255.255.255.0 eth.static_gw=172.20.51.1 network.dns=8.8.4.4
    

    I keep alternating between 8.8.8.8 and 8.8.4.4

    Anyone else experience this?



  • Most probably the program starts to run before the network is set up.

    See https://github.com/neonious/lowjs_esp32_examples/blob/master/drivers/industry/X20BC008U.js and there the function waitForEthernet to see how to wait for network. Works the same way with Wifi.



  • Thanks for the response.

    I don't think your idea solves the problem. The program tries to reconnect every 10 seconds (no reboots in between), but every time the program tries to connect it receives an exception with DNS error. The program ran uninterrupted for 3 days during the weekend.

    If I change the DNS IP before starting the program it works the first time until next reboot. Hence alternating between 8.8.8.8 and 8.8.4.4 between reboots. When I used DHCP instead of static IP it used to work every time.

    This morning the behaviour was gone without any changes to the program after setting DNS to 8.8.8.8. Maybe the problem is related to an expired DHCP lease (my case before changing from DHCP to static) or some internal caching expiration on the device? Note, when I used DHCP it seems like the device alternated between two leases which puzzled me. The RJ45 connector is used, WiFi is disabled.



  • Just to ensure your idea is not related to the problem:

    Prior to connection I added this:

    if (lowsys.status.eth != 'CONNECTED') {
        console.log('Ethernet cable not connected or network not available - waiting a bit');
        return;
    } else {
        console.log(' Ethernet cable is connected and network available');
    }
    

    The DNS problem occur even when status is connected.



  • @stennornes Have you excluded your ip = 172.20.51.96 address from your router's DHCP lease.



  • Yes, my DHCP range is from 172.20.51.100-200 and I have no IP conflicts. The multiple lease problem i had was only experienced when using DHCP. I think it may be the router that caused this specific problem and it is not related to the DNS issue.

    Currently I suspect DNS issue only happens after a restart(true) on the device.
    I am just about to test if it occurs using a restart(false).



  • The problem occurs after a change of static IP settings and a power reset (IP settings are changed within the program, not by calling lowsync).

    var settings = {
      eth: {
        enabled: true, 
        dhcp: "static",
        static_ip: ip,
        static_net: subnet,
        static_gw: gateway
      },
      network: {
        dns: dns
      }
    };
    var validate = {onlyValidate: false};
    var success = lowsys.setSettings(settings, validate);
    

    The problem does not occur after a restart(false).
    The problem occurs after a restart(true) or a physical power reset (power off/on).



  • Just some extra info:
    Everything works fine when connecting using the IP.
    The problem only occur when connecting using a domain-name where the DNS is in use.



  • I figured out a power cycle is all it takes to reproduce the problem regardless of how the settings are stored.

    This is the program stored on the device:

    var lowsys = require("lowsys");
    var net = require('net');
    
    console.log('Status', lowsys.status.eth);
    
    var client = new net.Socket();
    client.connect(80, 'google.com', function() {
      console.log('Connected');
    });
    
    client.on('error', function(err) {
      console.log('Error', err);
    });
    

    1 Set settings using lowsync

    node_modules/.bin/lowsync settings set eth.enabled=true eth.dhcp=static eth.static_ip=172.20.51.96 eth.static_net=255.255.255.0 eth.static_gw=172.20.51.1 network.dns=8.8.8.8
    

    2 Run program

    node_modules/.bin/lowsync sync --restart=true --transpile=false --monitor
    

    OUTPUT:
    Status CONNECTED
    Connected

    3 Full reset - unplug power supply for a few seconds

    4 Run program again

    node_modules/.bin/lowsync sync --restart=true --transpile=false --monitor
    

    OUTPUT:
    Status CONNECTED
    Error { Error: DNS server returned general failure (at getaddrinfo)
    at [anon] internal code: 'ESERVFAIL', errno: 3, syscall: 'getaddrinfo' }



  • This is definitly enough information to fix this issue when I am at that point of my TODO list this month 🙂 Thank you.


Log in to reply