jens-maus / node-unifi

NodeJS class for querying/controlling a UniFi-Controller (UDM-Pro, UDM-SE, UDM, UDR, UDW, CloudKey Gen1/Gen2) from Ubiquiti (www.ui.com)
MIT License
144 stars 51 forks source link

UDM Pro seems to need a URL without a port number #227

Open BobFrankston opened 10 months ago

BobFrankston commented 10 months ago

I'm running Unifi OS 3.2.7 and Unifi 8. I just switched from the USG. I found that in order to get node-unifi to work I had to modify the source code to change the URL to not have a port number. I tried ports 80, 443 and 8443 and all failed. I can't explain it -- is this a known problem

    //this._baseurl = new URL(`https://${options.host}:${options.port}`);
    this._baseurl = new URL(`https://${options.host}`);
BobFrankston commented 10 months ago

Uh oh - -it worked but now has stopped working so I don't know what is happening:

(node:41208) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
index.js:5
2023-12-21 20:10:11 Upsnarf: Logging in 
upsnarf.ts:145
login Request failed with status code 429
upsnarf.ts:59
AxiosError: Request failed with status code 429 getting info DID THE CONTROLLER CHANGE ? 
upsnarf.ts:194
2023-12-21 20:10:12 ERROR AxiosError: Request failed with status code 429  
upsnarf.ts:145
Uncaught AxiosError AxiosError
    at loadESM (internal/process/esm_loader:34:33)
    at processTicksAndRejections (internal/process/task_queues:95:5)
    --- await ---
    at runMainESM (internal/modules/run_main:98:21)
    at executeUserEntryPoint (internal/modules/run_main:131:5)
    at <anonymous> (internal/main/run_main_module:28:49)
esm_loader:34
Process exited with code 1

Perhaps an example with sample credentials would help (user:username;password; https://unifi}?

thib3113 commented 10 months ago

@BobFrankston it seems that now there is a rate limit on login on unifi . So, 429 seems to say you just got rate limited . But, it seems you can configure this limit : https://community.ui.com/questions/Unifi-API-Rate-Limited/ba82a718-9418-46b0-8f2f-235bfc647f9b#answer/0761c014-a393-432c-a792-48defcef3f5e