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

mDNS through the constructor parameter doesn't work #45

Open
bwucke opened this issue Sep 2, 2024 · 0 comments
Open

mDNS through the constructor parameter doesn't work #45

bwucke opened this issue Sep 2, 2024 · 0 comments

Comments

@bwucke
Copy link

bwucke commented Sep 2, 2024

I tried some debugging but found nothing - what you do in your code, other than reversed logic for the error message which should do nothing, is exactly what I'm doing. But mine works, yours doesn't. ¯\_(ツ)_/¯

void startWWWServer() {

    const char* host = "switch";
    //     LOG_F(("Setting mDNS hostname http://%s.local/\n",host));
    server = new AsyncFsWebServer(80, LittleFS, host);

    server->on("/", HTTP_GET, index_handler);
    server->on("/switch", HTTP_GET, switch_handler);
    server->on("/command", HTTP_POST, command_handler);

    server->onNotFound(not_found_handler);

    server->begin();
    
    // My workaround
    
    MDNS.end();
    LOG_F(("Setting mDNS hostname http://%s.local/\n",host));
    MDNS.begin(host);
    MDNS.addService("http", "tcp", 80);
    MDNS.setInstanceName("Power-switch");
}

With my workaround:

avahi-resolve-host-name switch.local
switch.local    192.168.2.98

With my workaround commented out:

root@octopi:/home/pi# avahi-resolve-host-name switch.local
Failed to resolve host name 'switch.local': Timeout reached

Arduino IDE 2.3.2, esp32 Arduino core 3.0.4, AsyncEspFsWebserver 1.0.7, board Nologo ESP32C3 SuperMini (it's an ESP32 S3 board, despite the name)


regarding reversed logic - it's a minor typo.

    if (!MDNS.begin(m_host.c_str())){
        log_error("MDNS responder started");
    }

Should be "MDNS responder failed to start".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant