fix: retry UDP discovery once if first attempt finds no devices

This commit is contained in:
tian 2026-05-06 14:29:19 +08:00
parent 7de906cd91
commit 40dead215e
2 changed files with 7 additions and 0 deletions

View File

@ -132,6 +132,9 @@ func (h *Handler) ensureDevicesLoaded() {
return
}
_, _ = h.discovery.SearchDefault()
if len(h.registry.GetDevices()) == 0 {
_, _ = h.discovery.SearchDefault()
}
}
func (h *Handler) ProxyAgent(w http.ResponseWriter, r *http.Request) {

View File

@ -704,6 +704,10 @@ func (u *UI) ensureDevicesLoaded() {
return
}
_, _ = u.discovery.SearchDefault()
// Retry once if discovery returned nothing (UDP broadcast can be lossy on some networks)
if len(u.registry.GetDevices()) == 0 {
_, _ = u.discovery.SearchDefault()
}
}
func (u *UI) pageDashboard(w http.ResponseWriter, r *http.Request) {