Can't connect GPy to pybytes with NB-IoT

  • Re: Can't connect Fipy via LTE NB-IoT to Pybytes

    Connecting my GPy to Pybytes via Wifi works fine, but I have a similar issue as above with NB-IoT. On booting the GPy with latest pybytes firmware:

    Firmware: 1.18.2.r6
    Pybytes: 0.9.12
    Pybytes configuration read from /flash/pybytes_config.json
    Initialized watchdog for WiFi and LTE connection with timeout 660000 ms
    LTE init(carrier=standard, cid=1)
    LTE attach(band=20, apn=lpwa.telia.iot, type=None)
    LTE connect()
    LTE is_connected()
    LTE connection established
    Unknown error while connecting to MQTT server [Errno 113] EHOSTUNREACH
    Unknown error while connecting to MQTT server [Errno 113] EHOSTUNREACH

    Quite close to connecting to Pybytes I think... Could this be DNS related?

    My carrier is Telia. These REPL lines give me perfect access to Internet:

    >>> import socket
    >>> from network import LTE
    >>> lte = LTE()
    >>> lte.send_at_cmd('AT!="addscanband band=20"')
    >>> lte.attach(band=20, apn="lpwa.telia.iot")
    >>> lte.isattached()
    >>> lte.connect()
    >>> lte.isconnected()
    >>> socket.dnsserver(0,'')
    >>> socket.dnsserver(1,'')
    >>> socket.dnsserver()
    ('', '')
    >>> print(socket.getaddrinfo("", 80)[0][-1])
    ('', 80)

    Grateful for your advice.
    // Erik

  • @Xykon Telia allows tcp/ip mqtt access.

    It was as I suspected, a DNS server issue. I solved it by modifying the pybytes source code to use Google DNS.

    diff --git a/lib/ b/lib/
    index b7c3f49..3d16201 100644
    --- a/lib/
    +++ b/lib/
    @@ -130,6 +130,10 @@ class PybytesConnection:
                     print("You need a device with FiPy or GPy firmware to connect via LTE")
                     return False
    +                # use Google DNS servers
    +                socket.dnsserver(0,'')
    +                socket.dnsserver(1,'')
                     from network import LTE
                     print_debug(1, 'LTE init(carrier={}, cid={})'.format(lte_cfg.get('carrier'), lte_cfg.get('cid', 1)))

    And also need to reset modem on boot-up, because otherwise it can hang when connecting to the MQTT server, for whatever reason (?):

    # -- run on boot-up
    from network import LTE
    print("Resetting modem...", end="\r")
    lte = LTE()
    print("Resetting modem... Done.")

    I have to disable pybytes autostart in the json file, to get this working, obviously.

    // Erik

  • administrators

    @ebran Are you sure Telia is allowing tcp/ip mqtt access to 3rd party platforms via NB-IoT? A lot of providers place restrictions on what you can do and only allow connectivity to their own proprietary platform. I've briefly looked through what's available on google and I only found information on how to connect to the Telia cloud platform through nb-iot.

Pycom on Twitter