Skip to content

ESP32 MDNS working only on one computer #3868

@PC-maniak

Description

@PC-maniak

Hardware:

Board: ESP32 Dev Module
Core Installation version: latest
IDE name: Arduino IDE
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10

Description:

MDNS works only on my computer .. on the other (local area network) I have to give an ip address ... and on my Android phone does not work - only ip ..

Sketch:

//Change the code below by your sketch
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <Update.h>
#include <SPIFFS.h>

const char* host = "nas-wifi";
const char* ssid = "****";
const char* password = "****";

WebServer server(80);

void setup() {
Serial.begin(115200);
 
  // Start SPIFFS Files System
  SPIFFS.begin();

  // Connect to WiFi network
  // Wait for connection
   WiFi.begin ( ssid, password );
  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 ); Serial.print ( "." );
  }
  // WIFI OK
  Serial.println ( "" ); 
  Serial.print ( "Connected to " ); Serial.println ( ssid );
  Serial.print ( "IP address: " ); Serial.println ( WiFi.localIP() );

  //use mdns for host name resolution*/
  if (!MDNS.begin(host)) { 
    Serial.println("Error setting up MDNS responder!");
    while (1) {
      delay(1000);
    }
  }
  Serial.println((String)"http://" + host);

 server.onNotFound([]() {                              // If the client requests any URI
    if (!handleFileRead(server.uri()))                  // send it if it exists
      server.send(404, "text/plain", "404: Not Found"); // otherwise, respond with a 404 (Not Found) error
  });
  
  server.begin();
  Serial.println("HTTP server started");
}

void loop() {
server.handleClient();
}

// MORE SERVER CODE HERE ...

Debug Messages:

Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions