nickovs / unificontrol

A high-level Python interface to the Unifi controller software
Apache License 2.0
96 stars 41 forks source link

UniFiOS API now very slow since UDM firmware 1.11 #31

Open stevehoek opened 2 years ago

stevehoek commented 2 years ago

I've been using the UDMsupport branch of this library in my project and it has been working great, up to and including UniFiOS 1.10 However, since upgrading this week to 1.11 the API calls are all taking much longer to return... device list, client list, client detail.

Is anyone else experiencing this?

clyra commented 2 years ago

yes, I'm seeing this too.

clyra commented 2 years ago

I'm trying to figure out what's happening but so far didnt had success. I'm also comparing this library to the one used by home-assistant (https://github.com/Kane610/aiounifi) and it seems that when the device is using the "unifi-os" you need to send the x-csrf-token (https://github.com/Kane610/aiounifi/blob/cb9f72c616706c078b8c84b3e822e2a223636a33/aiounifi/controller.py#L105).

So I added a self.headers variable to unificlient class and added this to the _execute:

        token = resp.headers.get("x-csrf-token")
        if not self.headers.get("x-csrf-token") and token:
            self.headers["x-csrf-token"] = token

but even with that, it still takes 60 seconds to get a reply (which I find very suspicious... is it some sort of timeout?).