-
Notifications
You must be signed in to change notification settings - Fork 2k
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
setHostname does not set the host name #1403
Comments
Exactly the same problem here. Same problem and possible solution ? prampec/IotWebConf#254 |
Thats the SSID, not the hostname |
Thank you @tablatronix for reply. |
startConfigPortal(SSID) also why are you starting cp AND using autoconnect? |
There must be a misunderstanding here. The issue is about the hostname. |
the code is a bit confusing, so i might have misread it, but can you try calling setupHostname(restart=False) after setHostname ? it looks like this is missing in the ap start sequence for ESP32 (also with restart=True .. just in case) |
|
yeah, please try that (making it public temporale). I am curious and i don't have a esp32 before weekend to test myself |
I 've tried what you suggest |
even the debug output the same? that sounds odd! |
No. The code is not missing. Same code for ESP32 and ESP8266. ESP32:
ROUTER:
ESP8266:
Router:
|
Looking at the logs, I suspect that the problem might be with the autoconnect feature of ESP32. I see that the connect time of ESP32 is only 827ms. I am thinking that as soon as the ESP32 restarts, it automatically connects to WiFi, BEFORE my code reaches the Update 1: |
I swear I test this every other week.. |
yup definitely an issue, I think there is some issue with when this is called or a race condition. |
yup ok so there seems to be something going on across versions. I need to find out if this changed or what *wm:[1] ESP SDK version: v4.4-beta1-189-ga79dc75f0a |
What version sdk you all on ? |
I pushed a test fix, needing test esp8266 and see if it broke, and older esp32 libs
|
I am on v4.4.1-1-gb8050b365e |
It works now for both ESP8266 and ESP32. |
Yeah i am looking into that also , it seems hostname MUST be set before wifi is enabled, used to be connected. I need to find out why this changed in the IDF or if there is just some bug in esp we can fix. If not I can find another wya, I just have ot be careful to not stop and start stuff if it causes even a 500ms delay in connections. |
I have the same issue with inability to set the Hostname. The Hostname seems to be the AP Hostname when the configuration was saved. Removing the WiFi.mode( WIFI_STA ); had no effect. Otherwise, WiFiManager has been wonderful and saved me a lot of time. |
hmm, still not working? I pushed a fix for this, are you using latest git? |
I did not know there was a fix and am using 2.0.9. I will update and test and let you know . . . Thank you. |
sorry ill try to cut a new beta |
I will wait for your new beta. |
I tried the 2.0.11beta firmware and still no success setting the Hostname. After calling the setHostname function the getHostname function returns the correct setHostname string but the actual Hostname on the wire is the original AP Hostname. I tried the following code at the end of Setup() and still no success. Serial.println( " AP soft Restart" ); I also cleared the lease from the router to make sure the router is not caching the Hostname and also confirmed using ping Hostname from the command line. |
Ill try to do it tonight |
The project is using the latest .12-beta you made available a couple of days ago. The project was started from an example file from 'Dronbot Workshop'. Everything works great except setHostname. The development environment is using VSCode and Platformio. Happy to post my source file at your request or if you would like to suggest I use one of the example files from the git page I would be happy to try that out. Have previously tried many different combinations of intermixing WiFi.h and WiFiManager.h library calls with no success. The Hostname is always the same and I check it using both my DD-WRT router which provides the DHCP and confirm using the command line 'ping Hostname' which has only ever responded to the Hostname esp32s2-69A284. Thank you for your time and effort creating, maintaining, and troubleshooting this library. |
I will test again with a basic example, and with an s2. What esp32 version you using? |
ESP32-S2-WROOM from DFRobot DFR0743-WROOM. Here is some setup info:
The setup is intended for a Adafruit saola board based on the esp32-s2-wrover module. I am using an esp32-s2-wroom module on my custom pcb since the Adafruit parts were out of stock when I began this project. As far as I can tell, the only difference is the WROVER has extra external serial RAM, PSRAM, which the WROOM does not have. Please let me know which basic example and I will test also. |
Confirmed, broken here, let me check esp32 again and make sure they didn't change something |
Added a fix, hostname must be set BEFORE any wifi on some versions of IDF, and it seems to differ last time i fixed this. SO DO NOT setmode() in your code and try this last commit and see if it works Afaik it is impossible to change hostname, I will work on how to stop and start wifi properly to get this working and to allow changes. Pretty sure wifi has to be turned off then back on, which is going to make connections take forever. So ideally just do NOT do anything wifi in your code before autoconnect. Another way to fix this, is to call WiFi.setHostname("whatnot") immediately after setup and if it fixes your issue then this bug is responsible. |
I have tried the WiFi.setHostname placed as soon as possible after the first call to WiFi to connect the Event messages to an event handler. It is also as soon as possible after the first call to wm which gets the MAC address so I can create the Hostname for the device. I will try out the new library in a couple of hours . . . |
I made the changes to my 2012-beta files as you suggested. The reported messages on my debug terminal now seem to show the Hostname has been changed. The device has changed to a different default Hostname: esp32s2-02003F as shown on the Router and verified by command line ping. Here is a list of the debug messages. Everywhere in debug messages where I read the Hostname, I now read it back from both the WiFi and wm. The debug messages show this and seem to show the new Hostname has been accepted although both the Router and command line ping show otherwise. Here are the Debug Messages:
|
Yeah unfortunately there is no way to get the actual hostname from the IDF, the esp library just returns what you last tried to set it to ( its just a local variable ) And mayh or may not actually get set in the wifi SDK. afaik it is not exposed in the IDF. So The only real test is to check your network. Maybe we can add a dns ping? shrug |
I am surprised the reconnect() did not work since it should request the DHCP all over again afaik. |
Ok I am testing some fixes to make sure this always works, good news it does not add too much to connection time to reset |
I look forward to your edits and will try them in the morning (in Sunny, Rain Soaked NE Florida). |
I need to test older IDF and esp32, I have a feeling they will need custom code to set hostname AFTER wifi_sta is up and not before. I am thinking pre 4.4. and arduino <2.0 |
Have you had any success? Is there anything I can do to help? |
Is it not working? |
Thank you. I missed the commit. I will test this on Monday and let you know. |
I had an issue while applying the changes to WiFiManager.cpp The line 3610 showing a change of only comments was found in my WiFiManager at line#3530 and the surrounding code lines matched. This tells me there are either some lines missing or something does not match. I am defficient in the use of .git. How can I make sure I have the files with your latest, correct, changes? I tried the changes as is and as far as I can tell using my pfsense router, Advanced IP Scanner and the command line, there is now a zero length Hostname and the device is only ping-able by IP. |
Wait - I copied the entire contents of the WiFiManager from github to my editor, line 3612 contains the correct code, and am recompiling. Same results. 0 lenght Hostname. I believe the failure is probably now my code which needs refactoring after all the tail chasing I have done to try and make this work. Please let me know which example I should try and How can I download the entrire WiFiManager library after the last three commits? |
I have no idea , you should be testing with this library master branch |
When I get the library master branch, it does not have the changes. I know I must be doing something wrong. Can you give me a .git command line to get the correct branch? |
@tablatronix Thank you for your help. The latest commit to master works and it works well. Thank you again for your time and I hope I have contributed to making the library better without wasting too much of your time. |
Related to: #1483 (comment) |
I think this is fixed now, there may be some wrong behavior in older IDF still, shrug |
sethostname: usa o miniaplicativo 'Rede' no 'Painel de controle' para definir |
sethostname: usa o miniaplicativo 'Rede' no 'Painel de controle' para definir |
I observed the same symptom on my ESP32 D1 R32 board, and came accross this issue thread while looking for a solution. Found this workaround for the symptom: btw: Thank You for providing this library! |
Basic Infos
Hardware
WiFimanager Branch/Release: Master v2.0.11-beta
ESP32 dev module
Description
setHostname does not set the host name.
Settings in IDE
Arduino IDE 1.8.16
ESP32 Core 1.0.6
WiFimanager Branch/Release: Master v2.0.11-beta
Sketch
Debug Messages
The host name is ESP32_1BA4AE30.
The text was updated successfully, but these errors were encountered: