Closed pax0707 closed 7 months ago
Strange, I've never had that issue. If it initially is working, but then after some time gives this error, I wonder if there is an issue with the client itself? Perhaps try adding this to see if this resolves the issue (to check if clients is an array):
if ($clients === false) {
echo "Error: Failed to retrieve clients from the UniFi Controller. Retrying in 60 seconds...\n";
sleep(60);
$unifiClient->logout();
$unifiClient = createUnifiClient();
continue;
}
// New section to add
if (!is_array($clients)) {
echo "Error in client data retrieval: Expected an array, received a different type. Attempting to reconnect to UniFi Controller...\n";
sleep(60);
$unifiClient->logout();
$unifiClient = createUnifiClient();
continue;
}
Let me know if this works and I can add it to the current code.
Got a new notification after edit and restarting.
Monitoring.
Thanks, keep me posted, it sounds to me like something weird happens with the controller and a reconnect would fix it
Looks to be working fine. No errors so far, tested moving my iPhone over WiFi networks, and notifications are triggered as expected.
New device found. Sending a notification.
Checking again in 60 seconds...
New device found. Sending a notification.
Checking again in 60 seconds...
No new devices found on the network.
Checking again in 60 seconds...
New device found. Sending a notification.
Checking again in 60 seconds...
Just pushed a fix for this. Thanks for the update! Let me know if you see any further issues.
After some time it starts spamming this in log (and not notifying ofc):