delian / node-unifiapi

UniFi API ported to Node.JS
GNU General Public License v3.0
49 stars 19 forks source link

SyntaxError using the CloudAPI/wrtc #11

Open skinnyjames opened 6 years ago

skinnyjames commented 6 years ago

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)
delian commented 6 years ago

This is weird, as I cannot see where exactly is the problem... Let me try the same test on my side

Delian

On Wed, Mar 14, 2018 at 11:03 PM Sean Gregory notifications@github.com wrote:

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)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/delian/node-unifiapi/issues/11, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZpXMRyKKpJpg_OZRrV60wu2uBMwOks5teZPEgaJpZM4SrPzz .

skinnyjames commented 6 years ago

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?