Closed xsp1989 closed 1 year ago
This is a strange bug since both are unrelated. I need to investigate
I used [#undef MQTT_HOST_DISCOVERY] to turn off MQTT and found that zigbee can be started normally, but in the previous test, I found that sometimes the Ethernet will be disconnected immediately after connecting, not sure whether it is related to this bug relationship, maybe there is a memory overflow somewhere?
The problem I located is that by calling MqttDiscoverServer()->MDNS.queryService()->mdns_query_ptr() as follows, the last function mdns_query_ptr() is set to block for 3000ms, resulting in a timeout. What do you think about this question. @s-hadinger
That's probably why we don't use MDNS in the standard builds. It generally brings more problems that it solves.
Indeed having MDNS blocking for 3000ms is way too much and will generate all sorts of malfunctioning in the zigbee code, and other stuff.
Unfortunately none of the Tasmota maintainers use MDNS.
I think in a gateway that supports Ethernet, set Ethernet to support, turn off WIFI by default, and then enable mdns device discovery, you can use Ethernet more easily, and you can do plug and play in addition to configuring MQTT. Currently disabled MQTT_HOST_DISCOVERY works fine.
I don't know enough about MDNS to help here
Reopening since I will need to explore mDNS for Matter support.
The main problem is #define MQTT_HOST_DISCOVERY
that tries in loop to connect to a MQTT service with a 3s timeout.
I see much more value in Tasmota advertizing its name in mDNS rather than discovering the MQTT server. I will disable #define MQTT_HOST_DISCOVERY
by default.
I agree with your approach, it doesn't make much sense for tasmota to actively discover other MQTT servers.
By the way, I think dual-core ESP32 is better to use RTOS, such as freeRTOS, when one core is blocked and waiting, the other core can continue to run, just like multi-core CPU. Of course, blocking waits in the operating system is a stupid idea
This is already the case with mdns in esp-idf. Even on single core, the mdns listener runs in a separate RTOS task with low priority.
The way it is currently coded, MQTT tries to connect, detects MDNS is enabled and does a MDNS query, that time outs after 3 seconds. I suppose it should be recoded as probing in background if MQTT MDNS exists and only if detected, start a MQTT connection (that would not time out).
Said differently, MDNS lookup should populate the MQTTHost entry, and later trigger a MQTT connection.
But as said, this use-case is of lesser importance.
@s-hadinger Why not remove completly mqtt broker mDNS discovery? It is always a bad idea not to know the IP of the broker (or having real DNS for). Since this is the first issue (i have seen for), it is not really used. Maybe as an enhancement a second (fallback) mqtt broker (like the two SSIDs)?
Let's keep it disabled by default. I'm always worried that someone is using it and finds it useful
Dual MQTT broker infrastructure would be something interresting to setup for a resilient system. In case some devices connects to the 2nd one because of a transcient connection issue, the 2 instances must be able to exchange messages to work as one. In theory it should never happen but I've learned not to count on "never". I believe 2 mosquitto instances can be connected to exchange messages but I'm not sure if this is a static configuration or if it can be dynamic.
If we want such behavior, it should be managed at Tasmota level. I.e. register a second MQTT host if the first fails. MDNS is not meant for that and having 2 MQTT brokers advertised on the same network will result in bad things happening.
Moreover, the two MQTT brokers need to communicate with each other...
That was for me the only aspect for mDNS beeing of any use. Understanding the complexity of a second broker, it is no reason for mDNS at all.
In my opinion, on embedded devices, the main role of mdns is to allow other devices to discover their own IP and display the services of the device, rather than the embedded device to discover other devices.
I still keep that mDNS is useful to connect from a web browser to a Tasmota device if you don't want to manage the list of dynamic IPs. Still keep in mind that mDNS is based on broadcast, so it won't traverse VLANs. If your PC is in a VLAN and Tasmota devices in another VLAN, mDNS is of no help. (or maybe tweaking your router)
At present, I have compiled a firmware that only supports Ethernet (WIFI is turned off by default), which can be used by plugging in the Internet cable, but if you need to know the IP address, you must log in to the router management page to view it. If you have mDNS, you can know the IP address of tasmota by scanning on your phone.
Yes, this is the use case for mDNS I find the most valuable. It works as long as you make the mDNS request on the same VLAN.
Closing, since the use case of the feature generating the issue is very limited. PRs to solve are welcome. The main devels will not work on this.
PROBLEM DESCRIPTION
A clear and concise description of what the problem is.
REQUESTED INFORMATION
Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!
Backlog Template; Module; GPIO 255
:Status 0
:TO REPRODUCE
Self compiled via Visual-Studio-Code and these defines to use
EXPECTED BEHAVIOUR
A clear and concise description of what you expected to happen.
If mdns is enabled and zigbee cannot complete initialization (including 6.7.8 and 6.7.9) when running, if mdns is turned off with setoption55 0, initialization can be completed normally
SCREENSHOTS
Unable to start running zigbee when mdns is running uart log:
If mdns is turned off with setoption55, zigbee can start normally
ADDITIONAL CONTEXT
Add any other context about the problem here.
(Please, remember to close the issue when the problem has been addressed)