arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.18k stars 4.8k forks source link

remote Matter devices causes frequent DNS lookups #20994

Closed marcusb closed 7 months ago

marcusb commented 7 months ago

PROBLEM DESCRIPTION

I have a Shelly 1 Plus configured as a Matter bridge for 5 other Tasmota and OpenBK devices. This works but I notice that Tasmota issues a DNS lookup every time it polls the remote devices (each device every 3 seconds). This isn't a big issue but might create quite a bit of DNS traffic if you have a many devices.

Could the DNS lookups be cached within their TTL?

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [x] Provide the output of this command: `Status 0`:
```lua
04:03:56.547 CMD: Status 0
04:03:56.556 MQT: stat/garage-shelly1/STATUS = {"Status":{"Module":0,"DeviceName":"garage-shelly1","FriendlyName":["garage-shelly1"],"Topic":"garage-shelly1","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0,"StatusRetain":0}}
04:03:56.611 MQT: stat/garage-shelly1/STATUS1 = {"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota32/tasmota32.bin","RestartReason":"Software reset CPU","Uptime":"0T02:47:37","StartupUTC":"2024-03-20T00:16:19","Sleep":50,"CfgHolder":4617,"BootCount":36,"BCResetTime":"2023-10-15T22:09:02","SaveCount":226}}
04:03:56.655 MQT: stat/garage-shelly1/STATUS2 = {"StatusFWR":{"Version":"13.4.0.3(9c34707-tasmota32)","BuildDateTime":"2024-03-19T21:25:41","Core":"2_0_14","SDK":"4.4.6.240105","CpuFrequency":160,"Hardware":"ESP32-U4WDH-D v3.0","CR":"436/699"}}
04:03:56.677 MQT: stat/garage-shelly1/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":2,"LogHost":"[redacted]","LogPort":514,"SSId":["[redacted]",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008009","2805C80001000600003C5A0A192800000000","00000080","00006000","00004000","00000020"]}}
04:03:56.721 MQT: stat/garage-shelly1/STATUS4 = {"StatusMEM":{"ProgramSize":1912,"Free":967,"Heap":78,"StackLowMark":2,"PsrMax":0,"PsrFree":0,"ProgramFlashSize":4096,"FlashSize":4096,"FlashChipId":"164020","FlashFrequency":40,"FlashMode":"DIO","Features":["0809","9F9AD7DF","0015A001","B7F7BFCF","05DA9BC4","E0360DC7","480840D2","20200000","D4BC482D","810A80B1","00000004"],"Drivers":"1,2,!3,!4,!5,7,!8,9,10,11,12,!14,!16,!17,!20,!21,!24,26,!27,29,!34,!35,38,50,52,!59,!60,62,!63,!66,!67,!68,82,!86,!87,!88,!121","Sensors":"1,2,3,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,26,31,34,37,39,40,42,43,45,51,52,55,56,58,59,64,66,67,74,85,92,95,98,103,105,109,127","I2CDriver":"7,8,9,10,11,12,13,14,15,17,18,20,24,29,31,36,41,42,44,46,48,58,62,65,69,76,77,82"}}
04:03:56.804 MQT: stat/garage-shelly1/STATUS5 = {"StatusNET":{"Hostname":"garage-shelly1-6752","IPAddress":"[redacted]","Gateway":"[redacted]","Subnetmask":"255.255.255.0","DNSServer1":"[redacted]","DNSServer2":"0.0.0.0","Mac":"B8:D6:1A:8A:9A:60","IP6Global":"[redacted]","IP6Local":"fe80::bad6:1aff:fe8a:9a60%st1","Ethernet":{"Hostname":"","IPAddress":"0.0.0.0","Gateway":"0.0.0.0","Subnetmask":"0.0.0.0","DNSServer1":"[redacted]","DNSServer2":"0.0.0.0","Mac":"00:00:00:00:00:00","IP6Global":"","IP6Local":""},"Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":16.0}}
04:03:56.872 MQT: stat/garage-shelly1/STATUS6 = {"StatusMQT":{"MqttHost":"[redacted]","MqttPort":1883,"MqttClientMask":"garage-shelly1","MqttClient":"garage-shelly1","MqttUser":"[redacted]","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}}
04:03:56.910 MQT: stat/garage-shelly1/STATUS7 = {"StatusTIM":{"UTC":"2024-03-20T03:03:56Z","Local":"2024-03-20T04:03:56","StartDST":"2024-03-31T02:00:00","EndDST":"2024-10-27T03:00:00","Timezone":"+01:00","Sunrise":"06:51","Sunset":"19:02"}}
04:03:56.939 MQT: stat/garage-shelly1/STATUS10 = {"StatusSNS":{"Time":"2024-03-20T04:03:56","Switch1":"OFF"}}
04:03:56.959 MQT: stat/garage-shelly1/STATUS11 = {"StatusSTS":{"Time":"2024-03-20T04:03:56","Uptime":"0T02:47:37","UptimeSec":10057,"Heap":75,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":40,"MqttCount":1,"Berry":{"HeapUsed":47,"Objects":643},"POWER":"OFF","Wifi":{"AP":1,"SSId":"[redacted]","BSSId":"[redacted]","Channel":11,"Mode":"11n","RSSI":100,"Signal":-48,"LinkCount":1,"Downtime":"0T00:00:04"}}}
04:03:57.007 MQT: stat/garage-shelly1/STATUS12 = {"StatusSTK":{"Exception":28,"Reason":"LoadProhibited","EPC":"4018b9b5","EXCVADDR":"b83fc03a","CallChain":["4018b9b2","4018ec0a","40193ac2","401849dd"]}}

TO REPRODUCE

Configuration -> Configure Matter -> "Add Remote Tasmota or OpenBK"

EXPECTED BEHAVIOUR

DNS lookups are cached within TTL, not looked up before every HTTP request to the remotes.

SCREENSHOTS

ADDITIONAL CONTEXT

(Please, remember to close the issue when the problem has been addressed)

s-hadinger commented 7 months ago

You need to check the network to know if an actual DNS query was made. The message is misleading, DNS resolved just means that the DNS lib did return a response, but it doesn't indicate if it was from the cache or from the network. I'm not even sure there is a way to get this information from LwIP.

II would argue that resolution in 0 ms or 1 ms are from cache, and 22/38 ms are from the server, but I may be wrong.

So unless you see actual request on the wire, DNS entries are supposed to be cached. Keep in mind that the cache is small though.