micropython / micropython/micropython

RPI PICO W Regression: Setting DNS results in address resolution failure

Open
#15,695 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug port-rp2
Dominant language
C
Stars
22.1k
Forks
9k
Avg merge
6d 4h
Merged PRs (30d)
16

Description

Port, board and/or hardware

RPI PICO W

MicroPython version

MicroPython v1.24.0-preview.224.g6c3dc0c0b on 2024-08-22; Raspberry Pi Pico W with RP2040

Reproduction
import socket
import network
import asyncio

async def test():
    print("Connecting to WiFi...")
    sta_if = network.WLAN(network.STA_IF)
    sta_if.active(True)
    sta_if.connect("---", "---")
    while not sta_if.isconnected():
        await asyncio.sleep_ms(100)

    print("Setting DNS...")
    cfg = list(sta_if.ifconfig())
    cfg[-1] = "8.8.8.8"
    sta_if.ifconfig(cfg)

    server, port = "blynk.cloud", 443

    print("Resolving IP...")
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    addr = socket.getaddrinfo(server, port)[0][-1]

    print("Connecting...")
    sock.connect(addr)

    print("OK")

asyncio.run(test())

Expected behaviour
MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico W with RP2040:
MPY: soft reboot
Connecting to WiFi...
Setting DNS...
Resolving IP...
Connecting...
OK
Observed behaviour
MicroPython v1.24.0-preview.224.g6c3dc0c0b on 2024-08-22; Raspberry Pi Pico W with RP2040:
MPY: soft reboot
Connecting to WiFi...
Setting DNS...
Resolving IP...
Traceback (most recent call last):
  File "main.py", line 22, in test       # socket.getaddrinfo
OSError: -2
Additional Information

No response

Code of Conduct

Yes, I agree

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied asyncio/socket.getaddrinfo reproduction on the Pico W with the cited MicroPython 1.24.0 preview and 1.23.0. Compare the network.WLAN ifconfig DNS-setting path and socket.getaddrinfo behavior; done means setting 8.8.8.8 no longer causes OSError: -2 and the connection reaches OK.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.