micropython / micropython/micropython-lib

esp32 UDP socket bind()/recvfrom(): incoming empty packet crashes the system

Open
#736 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
1.1k
Avg merge
7d 6h
Merged PRs (30d)
3

Description

I'm using the following image:

MicroPython v1.20.0-206-g33b403dfb-kaki5 on 2023-07-11; ESP32 CAMERA w/SSL (KAKI5) with ESP32 on an AiThinker ESP32-CAM.

When listening for incoming UDP packets, if the packet has a payload, everything works normally. If the packet is empty, instead of blocking, the receive loop begins looping very fast, receiving a bogus empty packet every time, which locks up the system.

Un-/comment MESSAGE="" after properly setting TARGET_IP in pc-tester.py (which is run from PC), and setting SSID and PASSWORD in notifications.py (which should be uploaded to mpy) to see the difference (you may also want to comment the wifi.ifconfig(...) line if using dynamic IP.

Notice the timestamps in the picture. For wrong.png, the timestamps are way too close, even though pc-tester.py is only sending once per second. The top picture is the wrong case, the bottom one is the correct case, when the udp packet has the payload foo. In the wrong case, the IP and port are then also reported incorrectly.

Is this a bug, or am I not paying attention to some quirk?

wrong
pc-tester.py.txt
notifications.py.txt
correct

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 pc-tester.py and notifications.py with MESSAGE empty and with a payload, using the ESP32-CAM setup described in the issue. Compare the receive-loop timing and reported IP and port; done means empty UDP packets no longer cause a rapid bogus receive loop or system lockup.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.