delian / node-unifiapi

UniFi API ported to Node.JS

Repository from Github https://github.comdelian/node-unifiapiRepository from Github https://github.comdelian/node-unifiapi

SyntaxError using the CloudAPI/wrtc

skinnyjames opened this issue · comments

Non-cloud version is working well, but I wanted to ssh into a device.

Tried to run the list_aps() and got the following error.

SyntaxError: Unexpected end of JSON input
    at Object.parse (native)
    at registerQ (/home/webdev/repos/ubiquity-toolkit/node_modules/node-unifiapi/lib/webrtc-request.js:417:63)
    at _q.(anonymous function).forEach.n (/home/webdev/repos/ubiquity-toolkit/node_modules/node-unifiapi/lib/webrtc-request.js:45:49)
    at Array.forEach (native)
    at WRTC.fireQ (/home/webdev/repos/ubiquity-toolkit/node_modules/node-unifiapi/lib/webrtc-request.js:45:36)
    at RTCDataChannel.channel.(anonymous function) [as onmessage] (/home/webdev/repos/ubiquity-toolkit/node_modules/node-unifiapi/lib/webrtc-request.js:255:26)
    at /home/webdev/repos/ubiquity-toolkit/node_modules/wrtc/lib/eventtarget.js:32:26
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I'm not sure if it helps, but I also sometimes get the following error:

SyntaxError: Unexpected token x in JSON at position 99422
    at Object.parse (native)
    at registerQ (/home/webdev/repos/ubiquity-toolkit/node_modules/node-unifiapi/lib/webrtc-request.js:417:63)
    at _q.(anonymous function).forEach.n (/home/webdev/repos/ubiquity-toolkit/node_modules/node-unifiapi/lib/webrtc-request.js:45:49)
    at Array.forEach (native)
    at WRTC.fireQ (/home/webdev/repos/ubiquity-toolkit/node_modules/node-unifiapi/lib/webrtc-request.js:45:36)
    at RTCDataChannel.channel.(anonymous function) [as onmessage] (/home/webdev/repos/ubiquity-toolkit/node_modules/node-unifiapi/lib/webrtc-request.js:255:26)
    at /home/webdev/repos/ubiquity-toolkit/node_modules/wrtc/lib/eventtarget.js:32:26
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I noticed that the output starts with undefined:1 when I console.log the error
Could it be that the data coming out of the cloud service is malformed?