esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

Networking broken on es8266 (minimal config included) #5632

Open ghost58400 opened 3 months ago

ghost58400 commented 3 months ago

The problem

Network sockets (at least UDP) does not work anymore on esp8266 platform, but works perfectly on esp32 arduino and libretiny, it may be linked to the introduction of IPv6 recently.

Which version of ESPHome has the issue?

2024.3.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP8266

Board

nodemcuv2, esp8285

Component causing the issue

All components using UDP sockets (at least)

Example YAML snippet

esphome:
  name: test-udp

esp8266:
  board: nodemcuv2

#esp32:
#  board: esp32dev
#  framework:
#    type: arduino

api:

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: test-udp
    password: !secret fallback_ap_password

captive_portal:

logger:
  level: VERY_VERBOSE

e131:
  method: multicast

light:
  - platform: partition
    name: "Partition Light"
    effects:
      - e131:
          universe: 1
    segments:
      - single_light_id: my_light_1
      - single_light_id: my_light_2

  - platform: monochromatic
    output: my_output
    id: my_light_1

  - platform: monochromatic
    output: my_output
    id: my_light_2

output:
  - platform: template
    id: my_output
    type: float
    write_action:
      - logger.log: "writing output"

Anything in the logs that might be useful for us?

No error during compilation and no error in logs at runtime. When using the above YAML on esp8266, nothing appears in the logs when sending a packet from an other machine :

echo -n "hello" | nc -u -w0 test-udp.local 5568

When flashing the same code on esp32 (uncommented esp32), the logs appears with the same command, indicating that esphome receives the UDP packet :

[V][e131:068]: Invalid packet received of size 5.

Additional information

Tested on multiple devices including nodemcuv2, esp8285, esp32, libretiny. Esp32, both arduino and esp-idf, and libretiny works perfectly, but esp8266 (and esp8285) does not work.

Also, the code provided in https://esphome.io/cookbook/lambda_magic.html#send-udp-commands has the same behaviour as e131 UDP listener, it works on esp32 and libretiny but not on esp8266. This means that sockets (at least UDP) does not work on esp8266 platform, both in listening and sending packets.

I also tried to use the Arduino's WifiUDP library, it works well on esp8266 inside esphome, so the problem comes from socket implementation in esphome.

ssieb commented 3 months ago

The socket library doesn't support UDP on ESP8266 or pico.

ghost58400 commented 3 months ago

Thank you for your insight, if it is normal, why is there no error message? The official components using UDP should not be marked compatible with esp8266 Ans also using the sockets library should trigger an error log if used with a custom component The documentation of cookbook sending UDP packet should also precise that esp8266 is not working with this code, users can loose a lot of time by trying this code since it doesn't work and gives no error message

I am certain that the sockets library was working on UDP esp8266 some time ago, I think that it is a regression and this explains why there is no documentation and error messages.

ssieb commented 3 months ago

UDP was never working in the sockets library on 8266. There's also the WifiUDP class, but it only works on Arduino.

ghost58400 commented 1 month ago

Hello, since esp8266 platform always uses Arduino, would it be possible to use WifiUDP inside Sockets on esp8266 platform ?