How to resolve ESP32 AP to a name?
How to resolve ESP32 AP to a name?
Hi All
I have an ESP32-S2-MINI and have a web server on port 80.
To connect to it I use (from a browser)
http://192.168.4.1
It is possible to use some technique to be able to browse to it by name instead of its IP address?
Eg.
http://MyESP32
(I have used NetBios to do something similar in the past on Ethernet)
Thanks in advance.
Regards
Mark
I have an ESP32-S2-MINI and have a web server on port 80.
To connect to it I use (from a browser)
http://192.168.4.1
It is possible to use some technique to be able to browse to it by name instead of its IP address?
Eg.
http://MyESP32
(I have used NetBios to do something similar in the past on Ethernet)
Thanks in advance.
Regards
Mark
Re: How to resolve ESP32 AP to a name?
Hi
If I use the standard ESP32-AT is this possible?
Regards
Mark
If I use the standard ESP32-AT is this possible?
Regards
Mark
Re: How to resolve ESP32 AP to a name?
Yes, standard ESP32-AT firmware has already include mDNS command.
For example, if you set the mDNS service by command: AT+MDNS=1,"espressif","_iot",80
and start a web server on port 80.
then after your mobile phone connected to ESP32's AP, open the browser and visit http://espressif.local, it's same to visit the http://192.168.4.1
For example, if you set the mDNS service by command: AT+MDNS=1,"espressif","_iot",80
and start a web server on port 80.
then after your mobile phone connected to ESP32's AP, open the browser and visit http://espressif.local, it's same to visit the http://192.168.4.1
Re: How to resolve ESP32 AP to a name?
Hi
Many thanks!!!
I tried
AT+MDNS=1,"espressif","_iot",80
and that did allow connecting on the ULR espressif.local
I haven't yet understood what the "_iot" means but this is a good start since it is much better than needing to know the IP address!
Regards
Mark
Many thanks!!!
I tried
AT+MDNS=1,"espressif","_iot",80
and that did allow connecting on the ULR espressif.local
I haven't yet understood what the "_iot" means but this is a good start since it is much better than needing to know the IP address!
Regards
Mark
Re: How to resolve ESP32 AP to a name?
"_iot" is just a demo, it indicates the service type that the host can serves. The real service type, you can refer to http://www.dns-sd.org/serviceTypes.html for more details.
once you set it, this service type should be in mDNS query and mDNS query response packets.
Read the mDNS services doc: https://docs.espressif.com/projects/esp ... index.html for more details.
~
once you set it, this service type should be in mDNS query and mDNS query response packets.
Read the mDNS services doc: https://docs.espressif.com/projects/esp ... index.html for more details.
~
Re: How to resolve ESP32 AP to a name?
Hi
Thank you.
It sounds that when using port 80 "http" would be the better service type entry to use.
Presently, although the resolution is working, it is taking about 15s before it operates. I retested with "http" set but it didn't seem to make any difference and it still takes a long time before it connection. In addition it often also stops responding (and takes again 15s before it continues) - but works normally if I use the IP address.
Although it works from my PC it doesn't work from my Android phone.
I'll keep investigating but presently the operation is not adequate for real use based on experiences to date.
Regards
Mark
Thank you.
It sounds that when using port 80 "http" would be the better service type entry to use.
Presently, although the resolution is working, it is taking about 15s before it operates. I retested with "http" set but it didn't seem to make any difference and it still takes a long time before it connection. In addition it often also stops responding (and takes again 15s before it continues) - but works normally if I use the IP address.
Although it works from my PC it doesn't work from my Android phone.
I'll keep investigating but presently the operation is not adequate for real use based on experiences to date.
Regards
Mark
Re: How to resolve ESP32 AP to a name?
Hi
After experimenting with different service types I find no change in behavior.
Also I have monitored the mDNS process and don't see that it is used in any of the queries or replies.
The problem at the moment is the time it takes to resolve - the browser spins for about 15s before it connects.
Then, after a short time of non-use it has to resolve again and the browser again spins for about 15s until it resolves again.
However i don't think it is a problem with the mDNS operation in the ESP since it does immediately respond with a "cache flush 192.168.4.1" but the PC only actually uses it after a number or repetitions.
I also see that the ESP32 gives the address only 2 minutes to live and this is probably why it keeps having to re-resolve, causing the subsequent slowness.
Regards
Mark
After experimenting with different service types I find no change in behavior.
Also I have monitored the mDNS process and don't see that it is used in any of the queries or replies.
The problem at the moment is the time it takes to resolve - the browser spins for about 15s before it connects.
Then, after a short time of non-use it has to resolve again and the browser again spins for about 15s until it resolves again.
However i don't think it is a problem with the mDNS operation in the ESP since it does immediately respond with a "cache flush 192.168.4.1" but the PC only actually uses it after a number or repetitions.
I also see that the ESP32 gives the address only 2 minutes to live and this is probably why it keeps having to re-resolve, causing the subsequent slowness.
Regards
Mark
Re: How to resolve ESP32 AP to a name?
Hi
Another point.
I don't see why the TCP port is required as a parameter since I also see no reference to the TCP port during the mDNS resolution.
Regards
Mark
Another point.
I don't see why the TCP port is required as a parameter since I also see no reference to the TCP port during the mDNS resolution.
Regards
Mark
Re: How to resolve ESP32 AP to a name?
i tried the mdns, and it seems work well on my side.
1. About the "TCP port is required as a parameter"
For a well-designed application protocol, the SRV record has a name of the form "<Instance>.<Service>.<Domain>"
and gives the target host and port where the service instance can be reached. you can refer to RFC6763 for more details.
About the port resolution, you can refer to RFC6763 section 5.
2. About the "ESP32 gives the address only 2 minutes to live".
IMHO, i don't think this is a place that affects latency or functionality. in RFC6762, section 10. it said:
"As a general rule, the recommended TTL value for Multicast DNS resource records with a host name as the resource record’s name
(e.g., A, AAAA, HINFO) or a host name contained within the resource record’s rdata (e.g., SRV, reverse mapping PTR record) SHOULD
be 120 seconds." so, it's reasonable for mdns. of course, you can change this TTL value at file:
In addition, capturing packets through wireshark, reading mDNS related protocols, and debugging mDNS (esp-at/managed_components/espressif__mdns) code may help quickly analyze mDNS issues.
1. About the "TCP port is required as a parameter"
For a well-designed application protocol, the SRV record has a name of the form "<Instance>.<Service>.<Domain>"
and gives the target host and port where the service instance can be reached. you can refer to RFC6763 for more details.
About the port resolution, you can refer to RFC6763 section 5.
2. About the "ESP32 gives the address only 2 minutes to live".
IMHO, i don't think this is a place that affects latency or functionality. in RFC6762, section 10. it said:
"As a general rule, the recommended TTL value for Multicast DNS resource records with a host name as the resource record’s name
(e.g., A, AAAA, HINFO) or a host name contained within the resource record’s rdata (e.g., SRV, reverse mapping PTR record) SHOULD
be 120 seconds." so, it's reasonable for mdns. of course, you can change this TTL value at file:
Code: Select all
esp-at/managed_components/espressif__mdns/private_include/mdns_private.h (L70 to L72)
Who is online
Users browsing this forum: ferrero and 9 guests