delian / node-unifiapi

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

Issues with example #4

Open JeffWScott opened 7 years ago

JeffWScott commented 7 years ago

Running your example code for the cloudapi I get these errors right after starting the node app.

ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM

Then if I let it sit I get this after about a minute followed by the app crashing.

Error UnifiAPI {
debugging: [Function],
netsite: [Function],
login: [Function],
logout: [Function],
authorize_guest: [Function],
unauthorize_guest: [Function],
kick_sta: [Function],
terminate_guest: [Function],
block_sta: [Function],
unblock_sta: [Function],
set_sta_note: [Function],
set_sta_name: [Function],
stat_sessions: [Function],
stat_daily_site: [Function],
stat_hourly_site: [Function],
stat_hourly_ap: [Function],
stat_sta_sessions_latest: [Function],
stat_auths: [Function],
stat_allusers: [Function],
list_guests: [Function],
list_guests2: [Function],
list_clients: [Function],
stat_client: [Function],
list_usergroup: [Function],
set_usergroup: [Function],
list_health: [Function],
list_dashboard: [Function],
list_users: [Function],
list_aps: [Function],
list_rogueaps: [Function],
list_sites: [Function],
stat_sites: [Function],
add_site: [Function],
remove_site: [Function],
list_wlan_groups: [Function],
stat_sysinfo: [Function],
list_self: [Function],
list_networkconf: [Function],
stat_voucher: [Function],
stat_payment: [Function],
create_hotspot: [Function],
list_hotspot: [Function],
create_voucher: [Function],
revoke_voucher: [Function],
list_portforwarding: [Function],
list_dynamicdns: [Function],
list_portconf: [Function],
list_extension: [Function],
list_settings: [Function],
restart_ap: [Function],
disable_ap: [Function],
enable_ap: [Function],
set_locate_ap: [Function],
unset_locate_ap: [Function],
site_ledson: [Function], site_ledsoff: [Function],
set_ap_radiosettings: [Function],
get_settings: [Function],
get_settings_by_key: [Function],
set_settings: [Function],
set_guest_access: [Function],
set_guestlogin_settings: [Function],
rename_ap: [Function],
set_wlansettings: [Function],
list_events: [Function],
list_wlanconf: [Function],
get_wlanconf: [Function],
list_alarms: [Function],
set_ap_led: [Function],
set_ap_name: [Function],
set_ap_wireless: [Function],
status: [Function],
set_ap_network: [Function],
request_spectrumscan: [Function],
set_site_descr: [Function],
set_site_settings: [Function],
add_hotspot2: [Function],
list_hotspot2: [Function],
delete_hotspot2: [Function],
set_hotspot2: [Function],
remove_wlanconf: [Function],
add_wlanconf: [Function],
sdn_register: [Function],
sdn_unregister: [Function],
sdn_stat: [Function],
sdn_onoff: [Function],
extend_voucher: [Function],
buildSSHSession: [Function],
getSDPOffer: [Function],
sshSDPAnswer: [Function],
closeSSHSession: [Function],
connectSSH: [Function],
getSshTurnServers: [Function],
getTurnCredentials: [Function],
username: 'unifi',
password: 'unifi',
baseUrl: '',
debug: false,
debugNet: false,
gzip: true,
site: 'default',
net:
{ login: [Function: login],
logout: [Function: logout],
req: [Function: req] } }
Segmentation fault

JeffWScott commented 7 years ago

Debug info if it helps....

De CloudAPI CloudAPI-request initialized with options { username: 'XXXX', password: 'XXXX', baseUrl: 'https://sso.ubnt.com/api/sso/v1', debug: true, wss: null, api: null, deviceId: 'XXXXXXXXXXX0000000001b083300000000001bfc73200000000XXXXXXXX', debugNet: false, gzip: true, wrtcOpen: false, site: 'default' } +0ms
UnifiAPI Debug is enabled +14ms
UnifiAPI UnifiAPI Initialized with options { baseUrl: '', debug: true, net: { login: [Function: login], logout: [Function: logout], req: [Function: req] } } +4ms
CloudAPI CloudAPI Initialized with options { deviceId: 'XXXXXXXXXXX0000000001b083300000000001bfc73200000000XXXXXXXX', username: 'XXXX', password: 'XXXXXXXX', debug: true } +8ms
CloudAPI CloudRequest /api/s/default/stat/sessions { type: 'all', start: 895516045.45, end: 1500316045450 } {} POST undefined +2ms
CloudAPI cloudLogin +2ms
CloudAPI Trying to log in with username: XXXX and password: XXXXXXXX +2ms
CloudAPI Successfuly logged in { username: 'XXXX',
fields_missing: [],
first_name: 'XXXX',
last_name: 'XXXX',
twofa_enabled: false,
is_verified: true,
session_ttl_seconds: null,
time_created: '2013-10-05T23:08:55Z',
curr_privacy_rev: 'REV2013-01-18',
accounts:
{ lithium: '138f7051-67fa-4f0d-ba13-9fd8e6e38d7c',
magento: '3f9382eb-efbd-496a-bcac-67d4dfe58528' },
ivr: '3714667440',
curr_termsrev: 'REV2013-01-18',
email: 'XX@XXX.XXX',
uuid: 'XXXXXXXXXXXXXXXXXXXXXXXX' } +797ms
WssAPI WssAPI-request initialized with options { debug: true, cookie: 'lithiumRest:ubnt=~225QTSOkse481Gne5~k6fYORZo9iZmYjeNDU23rkRmRz
-rZhgbEbyxF8PsbL_GxUBnobagLmo9Vs_F4Vrf3XZLwA1LtD22Yjtegir52JB71m2gWh8YOSyFmaq_1OVyINNNuBwpOFDkpQLm emcXYrMkWxQqL1q3JpVpE7vTLeGdAFZkAOo7m4I7EJOd6dnp8gQbLuUQAYI3JkiY9OSt04JT0mPzDP6I1_IjOTkwA..; lithiumSSO:ubnt=~2NvRVL4ah7GATSVY9~Q7zGKlF6QQJPci6imABMdibc2zKBeYg8JONFDKXs-Wbwg4cnTLKDWedIHiT5__PrJFrel3l3euR2ff7VaCCMiLyyQDXQ-T0RbTnmAf0JtK Y5ejoOV4X00FIwGBrgrxIGmqPNwd_408TkTYSBUu_ZaHUEE0EjiftCbf03GA6QUnMXz5dtnTdGMR_TW-QCxMs_dBcU34KJYYRM3bYfMUMfAA..; NODEBB_AUTH=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IkplZmZXU2NvdHQiLCJleHAiOjE1MDAzMTYzNDYsImlkIjoiZTU1NTVhY 2YtMTQ0Yy00YTk5LWExMjYtMjI4MTkwMGEwZDgwIiwicm9sZXMiOlsiQmV0YSBUZXN0ZXJzIiwiQ3VzdG9tIEF2YXRhciJdLCJlbWFpbCI6ImplZmZzY290dEBvdXRsb29rLmNvbSJ9.FWK6OFrmkVFxXQFlfmPQ9weWxZcpK43T91lIakDI8pTiTZU_0vdIMpofx7jYPVZOC1ujlzpXgAwBqPm4xaNFVg; UBIC_A UTH="fjF8bThJSjR1WW96ZkV0NVVkeWhBbHJmNFBxeGFqZDdOYytFNWIzMStqWEFwdnlvK0I2RU1VZXd0RXBGam9NVFhTM1BNSWx0akJyWDNmWngzQmhXL3hnNERUUVVXVmpLS1JjQWl1RldBcC9GdlBCTUJ4SUpKaFhCVjFDWlV5Ui9HckUvemZUUWZrbWZrN2YrR0Ewb29YODAwZFlicHA2MktLVC9URG1zSXlRN DViNVZoOXZZUE4zaVNwTXdiaUxNVzg0bHRLc2VzU1hEcVpZREdmOXEvZWdHL3hKUTc4MW5BPT18WjFlRVcwL1ZyVzM1WHQ1SzlmRlR1Q0ZhaXVVPXx1NXJpNWdxanoveXVBMmVyam5aTWdRPT18Vjhid2dFOGdJOUg3VitidUNEOEVDR2xNZ2hjPQ=="' } +4ms
WssAPI Connected wss://device-airos.svc.ubnt.com/api/airos/v1/unifi/events +319ms
WssAPI Message Sending: ping +4ms
CloudAPI WebSocket is connected +1ms
WssAPI Message Received: pong +65ms
CloudAPI Received response: string +623ms
CloudAPI now we have object +0ms
CloudAPI WEBRTC_WS_SENDING +1ms
WRTCRequest WRTC_PEER_OPEN { iceServers:
[ { urls: 'stun:global.stun.twilio.com:3478?transport=udp',
url: undefined },
{ urls: 'turn:global.turn.twilio.com:3478?transport=udp',
url: undefined,
username: 'XXXXXXXXXXXXXXXXXXXXXXXX',
credential: 'XXXXXXXXXXXXXXXXXXXXXXXX' } ] } { optional: [ { DtlsSrtpKeyAgreement: true }, { RtpDataChannels: true } ] } +1ms
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM WssAPI Message Sending: { message: 'action:request',
action: 'sdp_exchange',
action_id: '96093960-6b1d-11e7-8b51-4f9982e01e9a',
args:
{ device_id: 'XXXXXXXXXXX0000000001b083300000000001bfc73200000000XXXXXXXX',
payload:
{ username: 'XXXXXXXXXXXXXXXXXXXXXXXX',
password: 'XXXXXXXXXXXXXXXXXXXXXXXX',
ttl: 86400,
type: 'OFFER',
stunUri: 'stun:global.stun.twilio.com:3478?transport=udp',
turnUri: 'turn:global.turn.twilio.com:3478?transport=udp' } } } +81ms
WssAPI Message Received: {"message":"action:validation","action_id":"96093960-6b1d-11e7-8b51-4f9982e01e9a","result":"ok"} +73ms
WssAPI Message Received: {"message":"action:response","action_id":"96093960-6b1d-11e7-8b51-4f9982e01e9a","seq":1,"response":{"sdp":"v=0\no=- 17143524647 973948256 IN IP4 127.0.0.1\ns=EvoStream_WebRTC\nt=0 0\na=tool:ubnt_webrtc versi on v1.0.12\na=disable-sctp-checksum\na=msid-semantic: WMS\nm=application 1 DTLS/SCTP 5000\nc=IN IP4 0.0.0.0\na=ice-ufrag:a10rahxVcqVbJRUH\na=ice-pwd:FIAPTvwKjGdpfkAM5ulHDcQw\na=fingerprint:sha-256 DC:5C:04:CC:F4:99:67:CE:59:B5:BF:64:8 F:7C:BF:19:7C:46:E6:99:6D:82:67:A2:E8:96:67:74:63:8A:39:92\na=setup:actpass\na=mid:data\na=sctpmap:5000 webrtc-datachannel 1024\na=candidate:1331502582 1 udp 2130706431 2001:1970:4b9e:9800:46d9:e7ff:fe9f:3721 36749 typ host generation 0 ufrag a10rahxVcqVbJRUH\na=candidate:1841357947 1 udp 2130668031 192.168.0.7 54559 typ host generation 0 ufrag a10rahxVcqVbJRUH\na=candidate:3298782126 1 udp 1694460415 24.235.232.25 54559 typ srflx raddr 192.168.0.7 rport 54559 gen eration 0 ufrag a10rahxVcqVbJRUH\na=candidate:1951950972 1 udp 8388863 54.244.51.4 36692 typ relay raddr 24.235.232.25 rport 50951 generation 0 ufrag a10rahxVcqVbJRUH\n","sdpVersion":"3","webRtcId":36},"last":true} +2s
WssAPI Action Response { message: 'action:response',
action_id: '96093960-6b1d-11e7-8b51-4f9982e01e9a',
seq: 1,
response:
{ sdp: 'v=0\no=- 17143524647 973948256 IN IP4 127.0.0.1\ns=EvoStream_WebRTC\nt=0 0\na=tool:ubnt_webrtc version v1.0.12\na=disable-sctp-checksum\na=msid-semantic: WMS\nm=application 1 DTLS/SCTP 5000\nc=IN IP4 0.0.0.0\na=ice-ufrag:a1 0rahxVcqVbJRUH\na=ice-pwd:FIAPTvwKjGdpfkAM5ulHDcQw\na=fingerprint:sha-256 DC:5C:04:CC:F4:99:67:CE:59:B5:BF:64:8F:7C:BF:19:7C:46:E6:99:6D:82:67:A2:E8:96:67:74:63:8A:39:92\na=setup:actpass\na=mid:data\na=sctpmap:5000 webrtc-datachannel 1024\na=candidate:1331502582 1 udp 2130706431 2001:1970:4b9e:9800:46d9:e7ff:fe9f:3721 36749 typ host generation 0 ufrag a10rahxVcqVbJRUH\na=candidate:1841357947 1 udp 2130668031 192.168.0.7 54559 typ host generation 0 ufrag a10rahxVcq VbJRUH\na=candidate:3298782126 1 udp 1694460415 24.235.232.25 54559 typ srflx raddr 192.168.0.7 rport 54559 generation 0 ufrag a10rahxVcqVbJRUH\na=candidate:1951950972 1 udp 8388863 54.244.51.4 36692 typ relay raddr 24.235.232.25 rpor t 50951 generation 0 ufrag a10rahxVcqVbJRUH\n',
sdpVersion: '3',
webRtcId: 36 },
last: true } +0ms
CloudAPI WEBRTC_SDP_RECEIVING { message: 'action:response',
action_id: '96093960-6b1d-11e7-8b51-4f9982e01e9a',
seq: 1,
response:
{ sdp: 'v=0\no=- 17143524647 973948256 IN IP4 127.0.0.1\ns=EvoStream_WebRTC\nt=0 0\na=tool:ubnt_webrtc version v1.0.12\na=disable-sctp-checksum\na=msid-semantic: WMS\nm=application 1 DTLS/SCTP 5000\nc=IN IP4 0.0.0.0\na=ice-ufrag:a1 0rahxVcqVbJRUH\na=ice-pwd:FIAPTvwKjGdpfkAM5ulHDcQw\na=fingerprint:sha-256 DC:5C:04:CC:F4:99:67:CE:59:B5:BF:64:8F:7C:BF:19:7C:46:E6:99:6D:82:67:A2:E8:96:67:74:63:8A:39:92\na=setup:actpass\na=mid:data\na=sctpmap:5000 webrtc-datachannel 1024\na=candidate:1331502582 1 udp 2130706431 2001:1970:4b9e:9800:46d9:e7ff:fe9f:3721 36749 typ host generation 0 ufrag a10rahxVcqVbJRUH\na=candidate:1841357947 1 udp 2130668031 192.168.0.7 54559 typ host generation 0 ufrag a10rahxVcq VbJRUH\na=candidate:3298782126 1 udp 1694460415 24.235.232.25 54559 typ srflx raddr 192.168.0.7 rport 54559 generation 0 ufrag a10rahxVcqVbJRUH\na=candidate:1951950972 1 udp 8388863 54.244.51.4 36692 typ relay raddr 24.235.232.25 rpor t 50951 generation 0 ufrag a10rahxVcqVbJRUH\n',
sdpVersion: '3',
webRtcId: 36 },
last: true } +2ms
WRTCRequest WEBRTC_SET_REMOTEDESC { type: 'offer',
sdp: 'v=0\no=- 17143524647 973948256 IN IP4 127.0.0.1\ns=EvoStream_WebRTC\nt=0 0\na=tool:ubnt_webrtc version v1.0.12\na=disable-sctp-checksum\na=msid-semantic: WMS\nm=application 1 DTLS/SCTP 5000\nc=IN IP4 0.0.0.0\na=ice-ufrag:a10ra hxVcqVbJRUH\na=ice-pwd:FIAPTvwKjGdpfkAM5ulHDcQw\na=fingerprint:sha-256 DC:5C:04:CC:F4:99:67:CE:59:B5:BF:64:8F:7C:BF:19:7C:46:E6:99:6D:82:67:A2:E8:96:67:74:63:8A:39:92\na=setup:actpass\na=mid:data\na=sctpmap:5000 webrtc-datachannel 102 4\na=candidate:1331502582 1 udp 2130706431 2001:1970:4b9e:9800:46d9:e7ff:fe9f:3721 36749 typ host generation 0 ufrag a10rahxVcqVbJRUH\na=candidate:1841357947 1 udp 2130668031 192.168.0.7 54559 typ host generation 0 ufrag a10rahxVcqVbJ RUH\na=candidate:3298782126 1 udp 1694460415 24.235.232.25 54559 typ srflx raddr 192.168.0.7 rport 54559 generation 0 ufrag a10rahxVcqVbJRUH\na=candidate:1951950972 1 udp 8388863 54.244.51.4 36692 typ relay raddr 24.235.232.25 rport 5 0951 generation 0 ufrag a10rahxVcqVbJRUH\n' } +1ms
WRTCRequest onsignalingstatechange { type: 'signalingstatechange' } +16ms
WRTCRequest SIGNALING STATE have-remote-offer +1ms
WRTCRequest WEBRTC_CREATE_ANSWER +0ms
WRTCRequest WEBRTC_SET_LOCALDESCR RTCSessionDescription {
type: 'answer',
sdp: 'v=0\r\no=- 4353787558164367721 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 9 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\nb=AS:30\r\na=ice-ufrag:oxF2cAQj7rLCAo2R\r\na=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE\r \na=fingerprint:sha-256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD\r\na=setup:active\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n' } +13ms
WRTCRequest onsignalingstatechange { type: 'signalingstatechange' } +19ms
WRTCRequest SIGNALING STATE stable +1ms
WRTCRequest oniceconnectionstatechange { type: 'iceconnectionstatechange' } +0ms
WRTCRequest ICECONNECTION STATE checking +1ms
WRTCRequest WEBRTC_OPEN_CHANNEL api +1ms
WRTCRequest WEBRTC_WAIT_ICECANDIDATES RTCSessionDescription {
type: 'answer',
sdp: 'v=0\r\no=- 4353787558164367721 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=msid-semantic: WMS\r\nm=application 9 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\nb=AS:30\r\na=ice-ufrag:oxF2cAQj7rLCAo2R\r\na=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE\r \na=fingerprint:sha-256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD\r\na=setup:active\r\na=mid:data\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n' } +5ms
WRTCRequest onicegatheringstatechange { type: 'icegatheringstatechange' } +2ms
WRTCRequest ICEGATHERING STATE gathering +1ms
WRTCRequest onicecandidate RTCPeerConnectionIceEvent {
type: 'icecandidate',
candidate:
RTCIceCandidate {
candidate: 'candidate:4126825794 1 udp 2122260223 172.35.60.177 47682 typ host generation 0 ufrag oxF2cAQj7rLCAo2R',
sdpMid: 'data',
sdpMLineIndex: 0 } } +3ms
WRTCRequest Ive got RTCPeerConnectionIceEvent {
type: 'icecandidate',
candidate:
RTCIceCandidate {
candidate: 'candidate:4126825794 1 udp 2122260223 172.35.60.177 47682 typ host generation 0 ufrag oxF2cAQj7rLCAo2R',
sdpMid: 'data',
sdpMLineIndex: 0 } } v=0
o=- 4353787558164367721 2 IN IP4 127.0.0.1
s=-
t=0 0
a=msid-semantic: WMS
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
b=AS:30
a=ice-ufrag:oxF2cAQj7rLCAo2R
a=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE
a=fingerprint:sha-256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD
a=setup:active
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024
+1ms
WRTCRequest onicecandidate RTCPeerConnectionIceEvent {
type: 'icecandidate',
candidate:
RTCIceCandidate {
candidate: 'candidate:1220512899 1 udp 2122194687 127.0.0.2 34693 typ host generation 0 ufrag oxF2cAQj7rLCAo2R',
sdpMid: 'data',
sdpMLineIndex: 0 } } +1ms
WRTCRequest Ive got RTCPeerConnectionIceEvent {
type: 'icecandidate',
candidate:
RTCIceCandidate {
candidate: 'candidate:1220512899 1 udp 2122194687 127.0.0.2 34693 typ host generation 0 ufrag oxF2cAQj7rLCAo2R',
sdpMid: 'data',
sdpMLineIndex: 0 } } v=0
o=- 4353787558164367721 2 IN IP4 127.0.0.1
s=-
t=0 0
a=msid-semantic: WMS
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
b=AS:30
a=ice-ufrag:oxF2cAQj7rLCAo2R
a=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE a=fingerprint:sha-256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD
a=setup:active
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024
a=candidate:4126825794 1 udp 2122260223 172.35.60.177 47682 typ host generation 0 ufrag oxF2cAQj7rLCAo2R
+1ms
WRTCRequest onicecandidate RTCPeerConnectionIceEvent {
type: 'icecandidate',
candidate:
RTCIceCandidate {
candidate: 'candidate:3145310642 1 tcp 1518280447 172.35.60.177 44741 typ host tcptype passive generation 0 ufrag oxF2cAQj7rLCAo2R',
sdpMid: 'data',
sdpMLineIndex: 0 } } +84ms
WRTCRequest Ive got RTCPeerConnectionIceEvent {
type: 'icecandidate',
candidate:
RTCIceCandidate {
candidate: 'candidate:3145310642 1 tcp 1518280447 172.35.60.177 44741 typ host tcptype passive generation 0 ufrag oxF2cAQj7rLCAo2R',
sdpMid: 'data',
sdpMLineIndex: 0 } } v=0
o=- 4353787558164367721 2 IN IP4 127.0.0.1
s=-
t=0 0
a=msid-semantic: WMS
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
b=AS:30
a=ice-ufrag:oxF2cAQj7rLCAo2R
a=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE
a=fingerprint:sha-256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD
a=setup:active
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024
a=candidate:4126825794 1 udp 2122260223 172.35.60.177 47682 typ host generation 0 ufrag oxF2cAQj7rLCAo2R
a=candidate:1220512899 1 udp 2122194687 127.0.0.2 34693 typ host generation 0 ufrag oxF2cAQj7rLCAo2R
+0ms
WRTCRequest onicecandidate RTCPeerConnectionIceEvent {
type: 'icecandidate',
candidate:
RTCIceCandidate {
candidate: 'candidate:104624243 1 tcp 1518214911 127.0.0.2 56908 typ host tcptype passive generation 0 ufrag oxF2cAQj7rLCAo2R',
sdpMid: 'data',
sdpMLineIndex: 0 } } +1ms
WRTCRequest Ive got RTCPeerConnectionIceEvent {
type: 'icecandidate',
candidate:
RTCIceCandidate {
candidate: 'candidate:104624243 1 tcp 1518214911 127.0.0.2 56908 typ host tcptype passive generation 0 ufrag oxF2cAQj7rLCAo2R',
sdpMid: 'data',
sdpMLineIndex: 0 } } v=0
o=- 4353787558164367721 2 IN IP4 127.0.0.1
s=-
t=0 0
a=msid-semantic: WMS
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
b=AS:30
a=ice-ufrag:oxF2cAQj7rLCAo2R
a=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE
a=fingerprint:sha-256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD
a=setup:active
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024
a=candidate:4126825794 1 udp 2122260223 172.35.60.177 47682 typ host generation 0 ufrag oxF2cAQj7rLCAo2R
a=candidate:1220512899 1 udp 2122194687 127.0.0.2 34693 typ host generation 0 ufrag oxF2cAQj7rLCAo2R
+0ms
WssAPI Message Sending: ping +7s
WssAPI Message Received: pong +63ms
WRTCRequest onicegatheringstatechange { type: 'icegatheringstatechange' } +2s
WRTCRequest ICEGATHERING STATE complete +1ms
WRTCRequest onicecandidate RTCPeerConnectionIceEvent { type: 'icecandidate', candidate: null } +1ms
WRTCRequest Ive got RTCPeerConnectionIceEvent { type: 'icecandidate', candidate: null } v=0
o=- 4353787558164367721 2 IN IP4 127.0.0.1
s=-
t=0 0
a=msid-semantic: WMS
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
b=AS:30
a=ice-ufrag:oxF2cAQj7rLCAo2R
a=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE
a=fingerprint:sha-256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD
a=setup:active
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024
a=candidate:4126825794 1 udp 2122260223 172.35.60.177 47682 typ host generation 0 ufrag oxF2cAQj7rLCAo2R
a=candidate:1220512899 1 udp 2122194687 127.0.0.2 34693 typ host generation 0 ufrag oxF2cAQj7rLCAo2R
+0ms
WRTCRequest Candidate is empty, terminate the gathering +1ms
CloudAPI LocalData to send RTCSessionDescription {
type: 'answer',
sdp: 'v=0\no=- 4353787558164367721 2 IN IP4 127.0.0.1\ns=-\nt=0 0\na=msid-semantic: WMS\nm=application 9 DTLS/SCTP 5000\nc=IN IP4 0.0.0.0\nb=AS:30\na=ice-ufrag:oxF2cAQj7rLCAo2R\na=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE\na=fingerprint:sha- 256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD\na=setup:active\na=mid:data\na=sctpmap:5000 webrtc-datachannel 1024\na=candidate:4126825794 1 udp 2122260223 172.35.60.177 47682 typ h ost generation 0 ufrag oxF2cAQj7rLCAo2R\na=candidate:1220512899 1 udp 2122194687 127.0.0.2 34693 typ host generation 0 ufrag oxF2cAQj7rLCAo2R\n' } +0ms
CloudAPI line [ 'a=candidate:4126825794 1 udp 2122260223 172.35.60.177 47682 typ host generation 0 ufrag oxF2cAQj7rLCAo2R',
'a=candidate:1220512899 1 udp 2122194687 127.0.0.2 34693 typ host generation 0 ufrag oxF2cAQj7rLCAo2R' ] +1ms
WssAPI Message Sending: { message: 'action:request',
action: 'sdp_exchange',
action_id: '9ccaced0-6b1d-11e7-8b51-4f9982e01e9a',
args:
{ device_id: 'XXXXXXXXXXX0000000001b083300000000001bfc73200000000XXXXXXXX',
payload:
{ sdpAnswer: 'v=0\no=- 4353787558164367721 2 IN IP4 127.0.0.1\ns=-\nt=0 0\na=msid-semantic: WMS\nm=application 9 DTLS/SCTP 5000\nc=IN IP4 127.0.0.2\nb=AS:30\na=ice-ufrag:oxF2cAQj7rLCAo2R\na=ice-pwd:JJ0GIBnPrdzGuRlfbGZmGhFE\na=fi ngerprint:sha-256 4B:4D:C3:61:94:33:EA:3B:87:D9:C0:03:EA:E7:44:6D:38:D5:EC:9A:81:E7:D9:6E:F7:35:2D:05:A9:6C:31:AD\na=setup:active\na=mid:data\na=sctpmap:5000 webrtc-datachannel 1024\na=candidate:4126825794 1 udp 2122260223 172.35.60.1 77 47682 typ host generation 0 ufrag oxF2cAQj7rLCAo2R\na=candidate:1220512899 1 udp 2122194687 127.0.0.2 34693 typ host generation 0 ufrag oxF2cAQj7rLCAo2R\n',
type: 'ANSWER',
webRtcId: 36 } } } +1ms
WssAPI Message Received: {"message":"action:validation","action_id":"9ccaced0-6b1d-11e7-8b51-4f9982e01e9a","result":"ok"} +76ms
WssAPI Message Received: {"message":"action:response","action_id":"9ccaced0-6b1d-11e7-8b51-4f9982e01e9a","seq":1,"response":{"rc":0},"last":true} +134ms
WssAPI Action Response { message: 'action:response',
action_id: '9ccaced0-6b1d-11e7-8b51-4f9982e01e9a',
seq: 1,
response: { rc: 0 },
last: true } +1ms
CloudAPI Send test message +1ms
WRTCRequest The channel api is not yet open. Wait... +1ms
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest oniceconnectionstatechange { type: 'iceconnectionstatechange' } +558ms
WRTCRequest ICECONNECTION STATE failed +1ms
WRTCRequest The channel api is not yet open. Wait... +442ms
WRTCRequest The channel api is not yet open. Wait... +1s
WssAPI Message Sending: ping +679ms
WssAPI Message Received: pong +62ms
WRTCRequest The channel api is not yet open. Wait... +260ms
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WssAPI Message Sending: ping +669ms
WssAPI Message Received: pong +62ms
WRTCRequest The channel api is not yet open. Wait... +271ms
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
WssAPI Message Received: {"message":"sites-list:update","device_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","payload":{"sites_list":[{"_id":"XXXXXXXXXXXXXXXXXXXXXXXXX","attr_hidden":true,"attr_hidden_id":"super","attr_no_delete":true, "attr_no_edit":true,"key":"super","name":"super","subsystems":[{"num_pending":0,"subsystem":"wlan"},{"num_pending":0,"subsystem":"wan"},{"num_pending":0,"subsystem":"lan"}]},{"_id":"5813a1b7b30941039200b7a6","attr_hidden_id":"default" ,"attr_no_delete":true,"desc":"XXX XXX","name":"default","num_new_alerts":2,"subsystems":[{"num_adopted":3,"num_ap":3,"num_disabled":0,"num_disconnected":0,"num_guest":0,"num_pending":0,"num_user":3,"rx_bytes-r":1869,"status":"ok", "subsystem":"wlan","tx_bytes-r":18846},{"num_adopted":0,"num_disconnected":0,"num_gw":0,"num_pending":0,"status":"unknown","subsystem":"wan"},{"status":"unknown","subsystem":"www"},{"num_adopted":0,"num_disconnected":0,"num_pending":0 ,"num_sw":0,"status":"unknown","subsystem":"lan"}]}]}} +409ms
WRTCRequest The channel api is not yet open. Wait... +599ms
WssAPI Message Sending: ping +649ms
WssAPI Message Received: pong +66ms
WRTCRequest The channel api is not yet open. Wait... +285ms
WRTCRequest The channel api is not yet open. Wait... +1s
WRTCRequest The channel api is not yet open. Wait... +1s
CloudAPI Error in opening webrtc +1s
Error UnifiAPI {
debugging: [Function],
netsite: [Function],
login: [Function],
logout: [Function],
authorize_guest: [Function],

etc.....

delian commented 7 years ago

Yes. This is an issue related to the wrtc module. It is the one that crashes. I found out that it is quite unstable and the stability depends on what OS it has been running. It runs quite well on OSX and Linux Ubuntu Server version. I am using typically Node 6.9 in order to get the pre-compiled binary. What is the software set that you are using?

Delian

On Mon, Jul 17, 2017 at 8:26 PM, JeffWScott notifications@github.com wrote:

Running your example code for the cloudapi I get these errors right after starting the node app.

ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL ALSA lib control.c:953:(snd_ctl_open_noupdate) Invalid CTL ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM

Then if I let it sit I get this after about a minute followed by the app crashing.

Error UnifiAPI { debugging: [Function], netsite: [Function], login: [Function], logout: [Function], authorize_guest: [Function], unauthorize_guest: [Function], kick_sta: [Function], terminate_guest: [Function], block_sta: [Function], unblock_sta: [Function], set_sta_note: [Function], set_sta_name: [Function], stat_sessions: [Function], stat_daily_site: [Function], stat_hourly_site: [Function], stat_hourly_ap: [Function], stat_sta_sessions_latest: [Function], stat_auths: [Function], stat_allusers: [Function], list_guests: [Function], list_guests2: [Function], list_clients: [Function], stat_client: [Function], list_usergroup: [Function], set_usergroup: [Function], list_health: [Function], list_dashboard: [Function], list_users: [Function], list_aps: [Function], list_rogueaps: [Function], list_sites: [Function], stat_sites: [Function], add_site: [Function], remove_site: [Function], list_wlan_groups: [Function], stat_sysinfo: [Function], list_self: [Function], list_networkconf: [Function], stat_voucher: [Function], stat_payment: [Function], create_hotspot: [Function], list_hotspot: [Function], create_voucher: [Function], revoke_voucher: [Function], list_portforwarding: [Function], list_dynamicdns: [Function], list_portconf: [Function], list_extension: [Function], list_settings: [Function], restart_ap: [Function], disable_ap: [Function], enable_ap: [Function], set_locate_ap: [Function], unset_locate_ap: [Function], site_ledson: [Function], site_ledsoff: [Function], set_ap_radiosettings: [Function], get_settings: [Function], get_settings_by_key: [Function], set_settings: [Function], set_guest_access: [Function], set_guestlogin_settings: [Function], rename_ap: [Function], set_wlansettings: [Function], list_events: [Function], list_wlanconf: [Function], get_wlanconf: [Function], list_alarms: [Function], set_ap_led: [Function], set_ap_name: [Function], set_ap_wireless: [Function], status: [Function], set_ap_network: [Function], request_spectrumscan: [Function], set_site_descr: [Function], set_site_settings: [Function], add_hotspot2: [Function], list_hotspot2: [Function], delete_hotspot2: [Function], set_hotspot2: [Function], remove_wlanconf: [Function], add_wlanconf: [Function], sdn_register: [Function], sdn_unregister: [Function], sdn_stat: [Function], sdn_onoff: [Function], extend_voucher: [Function], buildSSHSession: [Function], getSDPOffer: [Function], sshSDPAnswer: [Function], closeSSHSession: [Function], connectSSH: [Function], getSshTurnServers: [Function], getTurnCredentials: [Function], username: 'unifi', password: 'unifi', baseUrl: '', debug: false, debugNet: false, gzip: true, site: 'default', net: { login: [Function: login], logout: [Function: logout], req: [Function: req] } } Segmentation fault

— 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/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZgvenX1l1CHfBiEo3Q7N48C33MJiks5sO6dwgaJpZM4OaWv7 .

JeffWScott commented 7 years ago

Ubuntu Server 14.04 Node 6.11.1

I've progressed with the app I'm making. I'm getting used to the API. It's also been a few years since I did anything in nodejs so I'm fumbling there as well.

I think I can get away with running this like a script, instead of requiring it to be up constantly. So hopefully the instability won't be an issue.

Thanks for the API. It's really good BTW!

delian commented 7 years ago

You can check the other project unificli where I am using this API to create cli for tests. It is eventually ment to be used from shell scripts, but is very buggy yet. However the code is small and simple and could be used as nice example for the api

On Jul 17, 2017 21:33, "JeffWScott" notifications@github.com wrote:

Ubuntu Server 14.04 Node 6.11.1

I've progressed with the app I'm making. I'm getting used to the API. It's also been a few years since I did anything in nodejs so I'm fumbling there as well.

I think I can get away with running this like a script, instead of requiring it to be up constantly. So hopefully the instability won't be an issue.

Thanks for the API. It's really good BTW!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/delian/node-unifiapi/issues/4#issuecomment-315858013, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZliZ4EYwUOJvDZNHQnjPFuBGgSkwks5sO7bpgaJpZM4OaWv7 .

JeffWScott commented 7 years ago

I'll check that out. Thanks!

JeffWScott commented 7 years ago

I'm hoping you can help me out a bit, because you have the most experience of anyone with this Unifi API.

I'm attempting to create an app that will contact all the Cloud Keys I have out at customer's sites and pull in the latest auto backup file. So that I can keep them offsite. For some reason Unifi only saves the backups locally and that's kind of pointless when a Cloud Key screws up (happens all the time).

My plan was to:

  1. Use your Cloud API to get all my Cloud Key instances attached to my Unifi Account on the Unifi Cloud.
  2. Then iterate over them to send an SSH command to send the file to an offsite server by:
    • Iterating over the AP list for each site using the CK Device ID.
    • Once I get one send it an SSH command to SCP the backup file, using the cloud key IP, to an offsite server. (Using the AP as kind of a Jump server to transmit the file because I don't think your API allows directly SSHing into the CK itself)

What I'm trying to do is prevent having to configure ports on the customer's site to SSH directly into the CK. That and keeping track of IPs and CK information for each customer because this information is only as good as someone capturing and updating it. I was hoping that just by adding a new CK to my account the auto backup would just work because my app would find it from the Unifi Cloud site on the next run.

I was able to get the API to return to me all the sites via your API that was easy and fantastic.

I'm not quite sure, at that point, how to then take say the Device ID of the site(Cloud Key) and query all the APs at that site.

My current logic works like this: let cloud = CloudAPI({username, password]) // to get an instance of my Cloud Account

cloud.self() .then(() => cloud.devices()) // gets me all the devices attached to my cloud account and all the information attached

//At this point I want to get all the APs attached to that each site's device_id. My thought was to create a new cloud instance with just the site's device ID, like this. let site = CloudAPI({device_id, username, password]) //And then use that instance to call the API to get the AP list.

site.api.list_aps() .then(done => console.log('Success',done)) //This doesn't work. And the only reason why I think is because I'm not understanding the relationship between the CloudAPI object and all the regular API calls.

Am I barking up the wrong tree with your API? Am I going to be able to do this or am I wasting my time here?

Any help would be appreciated.

Thanks!


Jeff Scott | C: 905-431-2191 | E: jeffscott@outlook.com


From: Delian Delchev notifications@github.com Sent: July 17, 2017 3:38:57 PM To: delian/node-unifiapi Cc: JeffWScott; Author Subject: Re: [delian/node-unifiapi] Issues with example (#4)

You can check the other project unificli where I am using this API to create cli for tests. It is eventually ment to be used from shell scripts, but is very buggy yet. However the code is small and simple and could be used as nice example for the api

On Jul 17, 2017 21:33, "JeffWScott" notifications@github.com wrote:

Ubuntu Server 14.04 Node 6.11.1

I've progressed with the app I'm making. I'm getting used to the API. It's also been a few years since I did anything in nodejs so I'm fumbling there as well.

I think I can get away with running this like a script, instead of requiring it to be up constantly. So hopefully the instability won't be an issue.

Thanks for the API. It's really good BTW!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/delian/node-unifiapi/issues/4#issuecomment-315858013, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZliZ4EYwUOJvDZNHQnjPFuBGgSkwks5sO7bpgaJpZM4OaWv7 .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/delian/node-unifiapi/issues/4#issuecomment-315859592, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEoU6e8oJmeL12yf1ZlI4jVy36b5wrcyks5sO7hQgaJpZM4OaWv7.

CornelSyrzysko commented 6 years ago

Hi Delian.

Thanks for the help on the wrtc problem. Unfortunately I need to bother you again with a problem I can't seem to figure out.

I need to connect to the unifi controller remotely with a express.js server I'm building. My problem is that when I try to use the node-unifiapi to login, I'm getting the following error: "Authentication error Error: Parse Error."

I tried using another library (node-unifi) to connect and login to the unifi controller and it worked. I used the same username and password. I would prefer using your api as it allows for better organisation and more specific functions.

This is my code (the baseurl, username and password has been changed for security purposes):

let express = require('express') , app = express() , port = process.env.PORT || 3000 , unifiapi = require('node-unifiapi');

let unifi = unifiapi({ baseUrl: 'http://192.168.0.2:8443', username: '#username', password: '#password', debug: true, // More debug of the API (uses the debug module) debugNet: true // Debug of the network requests (uses request module) });

app.get('/test', (req, res) => { unifi.login('#username','#password') //only to test login .then((data) => { console.log(data); }, (err) => { console.log('error: ',err); }); });

app.listen(port); console.log('App running on port ', port);

Any help you can give me will be much appreciated. Thank you.

delian commented 6 years ago

You are not bothering me, this is how the bugs are fixed ☺

I will try this script and I will tell you if I see the problem

From: CornelTolmay notifications@github.com Reply-To: delian/node-unifiapi reply@reply.github.com Date: Wednesday, May 16, 2018 at 08:51 To: delian/node-unifiapi node-unifiapi@noreply.github.com Cc: Delian Delchev delian.delchev@gmail.com, Comment comment@noreply.github.com Subject: Re: [delian/node-unifiapi] Issues with example (#4)

Hi Delian.

Thanks for the help on the wrtc problem. Unfortunately I need to bother you again with a problem I can't seem to figure out.

I need to connect to the unifi controller remotely with a express.js server I'm building. My problem is that when I try to use the node-unifiapi to login, I'm getting the following error: "Authentication error Error: Parse Error."

I tried using another library (node-unifi) to connect and login to the unifi controller and it worked. I used the same username and password. I would prefer using your api as it allows for better organisation and more specific functions.

This is my code (the baseurl, username and password has been changed for security purposes):

let express = require('express') , app = express() , port = process.env.PORT || 3000 , unifiapi = require('node-unifiapi');

let unifi = unifiapi({ baseUrl: 'http://192.168.0.2:8443', username: '#username', password: '#password', debug: true, // More debug of the API (uses the debug module) debugNet: true // Debug of the network requests (uses request module) });

app.get('/test', (req, res) => { unifi.login('#username','#password') //only to test login .then((data) => { console.log(data); }, (err) => { console.log('error: ',err); }); });

app.listen(port); console.log('App running on port ', port);

Any help you can give me will be much appreciated. Thank you.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.