Comments (15)
Can someone please adapt his/her local node-unifi
installation to incorporate the changes from commit bbdac99 which I just applied to try to fix potential issue with UniFiOS 3.2/UniFi network v8+ according to hints from @thib3113. And please report back if these changes fixes the issues or if there are additional / other erros popping up now when using the basic examples for using node-unifi when connecting to a UniFiOS 3.2+ driven system.
from node-unifi.
Looks very good. With the new unifi.js the login works again. No more error messages.
Here is the output in debug mode:
unifi.0 | 2023-11-09 18:42:51.232 | debug | Update done
unifi.0 | 2023-11-09 18:42:51.186 | debug | Search can't be optimized because wildcard not at the end, fallback to keys!: function(doc) { if (doc.type === 'state') emit(doc._id, doc) }
unifi.0 | 2023-11-09 18:42:51.171 | debug | Search can't be optimized because wildcard not at the end, fallback to keys!: function(doc) { if (doc.type === 'state') emit(doc._id, doc) }
unifi.0 | 2023-11-09 18:42:51.120 | debug | fetchHealth default: 5
unifi.0 | 2023-11-09 18:42:50.143 | debug | fetchClients default: 37
unifi.0 | 2023-11-09 18:42:50.100 | debug | fetchSiteSysinfo default: 1
unifi.0 | 2023-11-09 18:42:50.073 | debug | Update site: default
unifi.0 | 2023-11-09 18:42:50.067 | debug | fetchSites: default
unifi.0 | 2023-11-09 18:42:50.010 | debug | Login successful
unifi.0 | 2023-11-09 18:42:49.518 | debug | Update started
unifi.0 | 2023-11-09 18:42:49.517 | debug | updateInterval = 60
unifi.0 | 2023-11-09 18:42:49.517 | debug | controller = 192.168.1.1:443
unifi.0 | 2023-11-09 18:42:49.517 | info | UniFi adapter is ready
unifi.0 | 2023-11-09 18:42:49.499 | info | starting. Version 0.6.6 in /opt/iobroker/node_modules/iobroker.unifi, node: v18.18.2, js-controller: 5.0.16
unifi.0 | 2023-11-09 18:42:49.305 | debug | Plugin sentry Initialize Plugin (enabled=true)
host.Server | 2023-11-09 18:42:48.572 | info | instance system.adapter.unifi.0 started with pid 1041318
from node-unifi.
Please anyone listening: Provide example output and payloads demonstrating this issue!
from node-unifi.
here the login error, system iobroker Docker 9.0.1 at Synology RS1619xs, js-controller 5.0.16:
2023-11-09 07:20:47.408 - info: unifi.0 (1980) starting. Version 0.6.6 (non-npm: iobroker-community-adapters/ioBroker.unifi#853005de6c5d65b7a2d05df12e56569d72d1fc4b) in /opt/iobroker/node_modules/iobroker.unifi, node: v18.18.2, js-controller: 5.0.16
2023-11-09 07:20:47.450 - info: unifi.0 (1980) UniFi adapter is ready
2023-11-09 07:20:47.451 - debug: unifi.0 (1980) controller = 192.168.0.1:
2023-11-09 07:20:47.451 - debug: unifi.0 (1980) updateInterval = 60
2023-11-09 07:20:47.452 - debug: unifi.0 (1980) Update started
2023-11-09 07:20:48.176 - error: unifi.0 (1980) Error site undefined (data): {"error":{"code":401,"message":"Unauthorized"}}
2023-11-09 07:20:48.505 - error: unifi.0 (1980) [updateUnifiData-login site undefined] error: Request failed with status code 401, stack: AxiosError: Request failed with status code 401
at settle (/opt/iobroker/node_modules/node-unifi/node_modules/axios/lib/core/settle.js:19:12)
at IncomingMessage.handleStreamEnd (/opt/iobroker/node_modules/node-unifi/node_modules/axios/lib/adapters/http.js:570:11)
at IncomingMessage.emit (node:events:529:35)
at IncomingMessage.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1368:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
2023-11-09 07:20:47.408 - info: unifi.0 (1980) starting. Version 0.6.6 (non-npm: iobroker-community-adapters/ioBroker.unifi#853005de6c5d65b7a2d05df12e56569d72d1fc4b) in /opt/iobroker/node_modules/iobroker.unifi, node: v18.18.2, js-controller: 5.0.16
2023-11-09 07:20:47.450 - info: unifi.0 (1980) UniFi adapter is ready
2023-11-09 07:20:47.451 - debug: unifi.0 (1980) controller = 192.168.0.1:
2023-11-09 07:20:47.451 - debug: unifi.0 (1980) updateInterval = 60
2023-11-09 07:20:47.452 - debug: unifi.0 (1980) Update started
2023-11-09 07:20:48.176 - error: unifi.0 (1980) Error site undefined (data): {"error":{"code":401,"message":"Unauthorized"}}
2023-11-09 07:20:48.505 - error: unifi.0 (1980) [updateUnifiData-login site undefined] error: Request failed with status code 401, stack: AxiosError: Request failed with status code 401
at settle (/opt/iobroker/node_modules/node-unifi/node_modules/axios/lib/core/settle.js:19:12)
at IncomingMessage.handleStreamEnd (/opt/iobroker/node_modules/node-unifi/node_modules/axios/lib/adapters/http.js:570:11)
at IncomingMessage.emit (node:events:529:35)
at IncomingMessage.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1368:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
from node-unifi.
Please anyone listening: Provide example output and payloads demonstrating this issue!
If I would know how to provide that with the given example from first-steps.js than I would have done it. Even trying to alter the script through ChatGPT would not help me other than that it was telling: AxiosError: Request failed with status code 401 ;)
I'm happy that Ilovegym66) could provide some more info.
from node-unifi.
First I will add informations from here Art-of-WiFi/UniFi-API-client#202 . That you are using "Unifi OS 3.2.5 with controller 8.02 (Cloudkey gen2 plus)"
And after multiples tests, the problem doesn't come frome the controller version (aka the network application version) . But come from the version of unifi OS version .
With unifi OS 3.2 this part : https://github.com/jens-maus/node-unifi/blob/master/unifi.js#L3009-L3015 . Doesn't work correctly now (it can't detect unifios) .
from node-unifi.
With unifi OS 3.2 this part : https://github.com/jens-maus/node-unifi/blob/master/unifi.js#L3009-L3015 . Doesn't work correctly now (it can't detect unifios) .
Thanks for the hint, I also suspected that the identification of UniFiOS vs. non-UniFiOS could be the reason. Any hint why simply checking for the x-csrf-token
in the response is not enough anymore?
from node-unifi.
@jens-maus it seems thats unifios doesn't send the x-csrf-token
now .
I need to do more tests, but, regarding my code, previously I check like this :
//this is not unifiOS
if (resCheck.status === 302 && resCheck.headers.location === '/manage') {
curDebug('os found : not unifiOs');
this.unifiOs = false;
} else if (resCheck.status === 200 && resCheck.headers['x-csrf-token']) {
curDebug('os found : unifiOs');
this.unifiOs = true;
} else {
throw new ClientError('fail to detect unifiOs or not !', EErrorsCodes.FAIL_TO_DETECT_UNIFIOS);
}
So, maybe checking the status is enough ... but I can't get an unifi controller V8 (docker version not available) to test .
Checking another library, they are just checking the status : https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php#L172-L178
from node-unifi.
@jens-maus it seems thats unifios doesn't send the
x-csrf-token
now .
Has that been verified by someone? Because so far I haven't see any notification or post somewhere on that.
I need to do more tests, but, regarding my code, previously I check like this :
[...]
Thx. I will have a look if I can find something out and see if I can work on some early test version some of the early UniFiOS 3.2 users could then test.
So, maybe checking the status is enough ... but I can't get an unifi controller V8 (docker version not available) to test .
Yes, I also recognized that there isn't any docker image out yet with unifi network V8 which we could use for testing. Thus, we might have to wait a few weeks for more to come because I really don't want to upgrade my udm pro just to hit the same issue :)
Checking another library, they are just checking the status : https://github.com/Art-of-WiFi/UniFi-API-client/blob/master/src/Client.php#L172-L178
Good catch. But haven't @aroundmyroom reported that also the UniFi-API-Client since the UniFiOS 3.2 upgrade (cf. Art-of-WiFi/UniFi-API-client#202)?
from node-unifi.
Good catch. But haven't @aroundmyroom reported that also the UniFi-API-Client since the UniFiOS 3.2 upgrade (cf. Art-of-WiFi/UniFi-API-client#202)?
yes ... I don't know ... I will try to get a php setup (not the time for the moment)
Has that been verified by someone? Because so far I haven't see any notification or post somewhere on that.
no idea ... I just got multiple notifications from @aroundmyroom ( API-Client and here ) . So I've upgraded my UDM pro to check ( upgrading only network >8 works, but upgrading unifiOS stop working ) . So, I just debug on my library, and I found that the csrf header is not here .
from node-unifi.
uhm..
I initially asked the developer of the tool I use to fix the issue, but he is reluctant as he only wants to support production version not early releases (Which I can understand totally)
So I wondered and that's my bad that the library was giving an issue not thinking about npm-unifi So I asked around to get some feedback (the php library) without proper testing. The feedback came with positive result that there was no issue in that library .. Ah .. if it is not a generic problem than it is something else. I than realised that npm-unifi was used
Hence my request / testing with the test samples..
I understand that I gave the impression towards @thib3113 and the dev op the PHP library that there was a bug in the PHP part but it was not.
from node-unifi.
Thank you all!
Works Perfect with UDM Pro 3.2.6 and Network 8.0.6
from node-unifi.
Yes .. the application I use is working again now I have replaced the unifi.js
from node-unifi.
Same here. Application (iobroker in my case) is working again.
from node-unifi.
Issue should be fixed with the latest node-unifi 2.5.0 version. Thanks to everyone!
from node-unifi.
Related Issues (20)
- [INFORMATION] Websockets
- Failed login doesn't reject HOT 1
- controller.createWLan give unsupported format in WlanConf payload. HOT 2
- 403 error on new 7.1.61 Unifi Network on cloud key Gen2 and Invalid CSRF Token HOT 8
- ioBroker - Warning HOT 1
- CSRF token not always set HOT 8
- InvalidAccessToken error HOT 3
- WebSocket crash on line 2922 HOT 1
- What need to be enabled on Controller's interface to allow websocket listen HOT 3
- setDeviceSettingsBase restarts UniFi Flex HOT 4
- Websocket - self-hostd UniFi controller software
- Websocket - Disconnect after every ~1 hour - need support HOT 2
- UDM Pro seems to need a URL without a port number HOT 2
- Critical Notifications Query Parameter in WebSocket URL
- Missing wan2 support on site statistics. HOT 1
- Missing list_device_name_mappings() and stat_full_status()
- FlexHD LED colour
- 2FA Support HOT 1
- getFullStatus and getDeviceNameMappings returning undefined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-unifi.