Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service port=0 in mdns_service_add causes a error (IDFGH-13429) #14335

Open
3 tasks done
nopnop2002 opened this issue Aug 8, 2024 · 4 comments
Open
3 tasks done

service port=0 in mdns_service_add causes a error (IDFGH-13429) #14335

nopnop2002 opened this issue Aug 8, 2024 · 4 comments
Assignees
Labels
Status: Opened Issue is new Type: Bug bugs in IDF

Comments

@nopnop2002
Copy link

nopnop2002 commented Aug 8, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.2.2-420-gc4fc74a6de

Espressif SoC revision.

Chip is ESP32D0WDQ6 (revision 1)

Operating System used.

Linux

How did you build your project?

Command line with CMake

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32 Development Board

Power Supply used.

USB

What is the expected behavior?

service port=0 in mdns_service_add not causes a error.

What is the actual behavior?

service port=0 in mdns_service_add causes a error

Steps to reproduce.

    //initialize mDNS
    ESP_ERROR_CHECK( mdns_init() );
    //set mDNS hostname (required if you want to advertise services)
    ESP_ERROR_CHECK( mdns_hostname_set(CONFIG_MY_HOSTNAME));
    ESP_LOGI(TAG, "mdns hostname set to: [%s]", CONFIG_MY_HOSTNAME);

    //initialize service
    //ESP_ERROR_CHECK( mdns_service_add(NULL, "_device-info", "_tcp", 80, NULL, 0) );
    ESP_ERROR_CHECK( mdns_service_add(NULL, "_device-info", "_tcp", 0, NULL, 0) );

Debug Logs.

ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x400d69ae
0x400d69ae: initialise_mdns at /home/nop/rtos/esp-idf-mdns/query-host1/main/main.c:144 (discriminator 1)

file: "./main/main.c" line 144
func: initialise_mdns
expression: mdns_service_add(NULL, "_device-info", "_tcp", 0, NULL, 0)

abort() was called at PC 0x40089257 on core 0
0x40089257: _esp_error_check_failed at /home/nop/esp-idf/components/esp_system/esp_err.c:50

More Information.

The samba service on the Linux server registers the service on port #445 and #0.

$ avahi-browse -art
+ enp2s0 IPv6 VOYAGER                                       _device-info._tcp    local
+ enp2s0 IPv4 VOYAGER                                       _device-info._tcp    local
+ enp2s0 IPv6 VOYAGER                                       Microsoft Windows Network local
+ enp2s0 IPv4 VOYAGER                                       Microsoft Windows Network local

= enp2s0 IPv6 VOYAGER                                       Microsoft Windows Network local
   hostname = [voyager.local]
   address = [fe80::78dc:5b71:a1bd:380a]
   port = [445]
   txt = []
= enp2s0 IPv6 VOYAGER                                       _device-info._tcp    local
   hostname = [voyager.local]
   address = [fe80::78dc:5b71:a1bd:380a]
   port = [0]
   txt = ["model=MacSamba"]
= enp2s0 IPv4 VOYAGER                                       Microsoft Windows Network local
   hostname = [voyager.local]
   address = [192.168.10.39]
   port = [445]
   txt = []
= enp2s0 IPv4 VOYAGER                                       _device-info._tcp    local
   hostname = [voyager.local]
   address = [192.168.10.39]
   port = [0]
   txt = ["model=MacSamba"]

It works correctly unless port # is 0.
However, Service Type in device-info does not have port #.

    //initialize mDNS
    ESP_ERROR_CHECK( mdns_init() );
    //set mDNS hostname (required if you want to advertise services)
    ESP_ERROR_CHECK( mdns_hostname_set(CONFIG_MY_HOSTNAME));
    ESP_LOGI(TAG, "mdns hostname set to: [%s]", CONFIG_MY_HOSTNAME);

    //initialize service
    ESP_ERROR_CHECK( mdns_service_add(NULL, "_device-info", "_tcp", 80, NULL, 0) );
    //ESP_ERROR_CHECK( mdns_service_add(NULL, "_device-info", "_tcp", 0, NULL, 0) );
$ avahi-browse -art
= enp2s0 IPv4 esp32-mdns1                                   _device-info._tcp    local
   hostname = [esp32-mdns1.local]
   address = [192.168.10.115]
   port = [80]
   txt = []

About device-info

http://www.dns-sd.org/servicetypes.html

device-info     Device Info
                Stuart Cheshire <cheshire at apple.com>, Marc Krochmal <marc at apple.com>
                Not a service type. Special name reserved for DNS-SD device info.
@nopnop2002 nopnop2002 added the Type: Bug bugs in IDF label Aug 8, 2024
@github-actions github-actions bot changed the title service port=0 in mdns_service_add causes a error service port=0 in mdns_service_add causes a error (IDFGH-13429) Aug 8, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 8, 2024
david-cermak added a commit to david-cermak/esp-protocols that referenced this issue Jan 10, 2025
@david-cermak
Copy link
Collaborator

Thanks for reporting, fixing in espressif/esp-protocols#730

@nopnop2002
Copy link
Author

nopnop2002 commented Jan 10, 2025

@david-cermak

With this fix, will the following code work?

ESP_ERROR_CHECK( mdns_service_add(NULL, "_device-info", "_tcp", 0, NULL, 0) );

@david-cermak
Copy link
Collaborator

Seems like it:

    ESP_ERROR_CHECK( mdns_init() );
    ESP_ERROR_CHECK( mdns_hostname_set(hostname) );
    ESP_LOGI(TAG, "mdns hostname set to: [%s]", hostname);
    ESP_ERROR_CHECK( mdns_instance_name_set(EXAMPLE_MDNS_INSTANCE) );
    ESP_ERROR_CHECK( mdns_service_add(NULL, "_device-info", "_tcp", 0, NULL, 0) );
$ avahi-browse -a -r
+ enpxxxx IPv6 ESP32 with mDNS                               _device-info._tcp    local
= enpxxxx IPv6 ESP32 with mDNS                               _device-info._tcp    local
   hostname = [esp32-mdns.local]
   address = [fe80::xxxx:xxxx:xxxx:xxxx]
   port = [0]
   txt = []

@nopnop2002
Copy link
Author

nopnop2002 commented Jan 10, 2025

I use this.
https://components.espressif.com/components/espressif/mdns/versions/1.4.3

but don't work.

    // initialize mDNS
    ESP_ERROR_CHECK( mdns_init() );

    // set mDNS hostname
    ESP_ERROR_CHECK( mdns_hostname_set("esp32-server") );

    // set default mDNS instance name
    ESP_ERROR_CHECK( mdns_instance_name_set("ESP32 with mDNS") );

    // add service
    //ESP_ERROR_CHECK( mdns_service_add(NULL, "_device-info", "_tcp", 80, NULL, 0) );
    ESP_ERROR_CHECK( mdns_service_add(NULL, "_device-info", "_tcp", 0, NULL, 0) );
$ cat idf_component.yml
## IDF Component Manager Manifest File
dependencies:
  espressif/mdns:
    version: "^1.4.3"
    rules:
      - if: "idf_version >=5.0"

$ head managed_components/espressif__mdns/CHANGELOG.md
# Changelog

## [1.4.3](https://github.com/espressif/esp-protocols/commits/mdns-v1.4.3)

### Features

- support zero item when update subtype ([5bd82c01](https://github.com/espressif/esp-protocols/commit/5bd82c01))

## [1.4.2](https://github.com/espressif/esp-protocols/commits/mdns-v1.4.2)

I use ipv4 address.

$ avahi-browse -a -r
+ enp2s0 IPv4 ESP32 with mDNS                               _device-info._tcp    local
= enp2s0 IPv4 ESP32 with mDNS                               _device-info._tcp    local
   hostname = [esp32-server.local]
   address = [192.168.10.109]
   port = [80]
   txt = []

My logging:

ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x400d7911
--- 0x400d7911: initialize_mdns at /home/nop/rtos/mdns-service-add/main/main.c:69 (discriminator 1)

file: "./main/main.c" line 69
func: initialize_mdns
expression: mdns_service_add(NULL, "_device-info", "_tcp", 0, NULL, 0)

abort() was called at PC 0x40089597 on core 0
--- 0x40089597: _esp_error_check_failed at /home/nop/esp-idf/components/esp_system/esp_err.c:49



Backtrace: 0x40081a76:0x3ffbaad0 0x400895a1:0x3ffbaaf0 0x4009124d:0x3ffbab10 0x40089597:0x3ffbab80 0x400d7911:0x3ffbabb0 0x400d7b9e:0x3ffbabf0 0x40158707:0x3ffbac10 0x4008a0ed:0x3ffbac40
--- 0x40081a76: panic_abort at /home/nop/esp-idf/components/esp_system/panic.c:463
0x400895a1: esp_system_abort at /home/nop/esp-idf/components/esp_system/port/esp_system_chip.c:92
0x4009124d: abort at /home/nop/esp-idf/components/newlib/abort.c:38
0x40089597: _esp_error_check_failed at /home/nop/esp-idf/components/esp_system/esp_err.c:49
0x400d7911: initialize_mdns at /home/nop/rtos/mdns-service-add/main/main.c:69 (discriminator 1)
0x400d7b9e: app_main at /home/nop/rtos/mdns-service-add/main/main.c:180
0x40158707: main_task at /home/nop/esp-idf/components/freertos/app_startup.c:208
0x4008a0ed: vPortTaskWrapper at /home/nop/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants