delian / node-unifiapi

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

WRTC not working on Azure #10

Closed ianisms closed 6 years ago

ianisms commented 6 years ago

Azure App Service is not happy with the wrtc lib. Trying to use a different webrtc lib but not having any luck. Both easyrtc and webrtc.io fail in the same fashion.

My config:

import mywrtc from 'webrtc.io'; // import mywrtc from 'easyrtc';
...
this.unifiCloud = uCloud({
    deviceId: this.config.controllerDeviceId,
    username: this.config.username,
    password: this.config.password,
    webrtc: mywrtc,
    debug: app.logger.level === 'debug',
}).api;

And then after making a call using the api like so:

this.unifiCloud.authorize_guest(
        guest.macAddr,
        validMinutes
    ).then((data) => {
        resolve(data);
    }, (err) => {
        reject(err);
    });

I get the following error in the log (showing relevant part):

  WssAPI Connected wss://device-airos.svc.ubnt.com/api/airos/v1/unifi/events +392ms
  WssAPI Message Sending:  ping +0ms
  CloudAPI WebSocket is connected +2ms
  WssAPI Message Received: pong +82ms
  CloudAPI Received response: string +420ms
  CloudAPI now we have object +0ms
  CloudAPI WEBRTC_WS_SENDING +2ms
  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: 'UN',
       credential: 'PW' } ] } { optional: [ { DtlsSrtpKeyAgreement: true }, { RtpDataChannels: true } ] } +0ms
  CloudAPI Error in opening webrtc +1ms
(node:22168) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot create property 'message' on string 'Could not authorize'
(node:22168) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  WssAPI Message Sending:  ping +9s
  WssAPI Message Received: pong +81ms

Any ideas?

ianisms commented 6 years ago

I should say that wrtc (version 0.65) works fine on Windows 10 but not Windows Server (or at least the version of Windows Server used in App Services). I could definitely get this running in a VM and/or a container but, my goal is to get this running in Azure App Services.

delian commented 6 years ago

This is weird. As I am not the maintainer of the WRTC module, I can only forward your observations to them. However, I shall mention that the node-unifiapi is not limited only to WRTC. Any compatible module (by compatible, I mean implementing the standard WRTC api calls) would work. You could probably test electron-webrtc (although, it uses a lot of memory and it is slower) and some of the others available for nodejs. My personal opinion is that wrtc is the best one, although that doesnt mean good. Node.JS for the moment lack standard DTLS and SCTP API (the major issue is actually the DTLS) and as a result in order to get webrtc working the developers must bind external libraries. WRTC module is based on poorly cut-off code from an old firefox and even the compilation of it is quite tricky.

Delian

On Fri, Jan 26, 2018 at 7:31 PM, Ian Bennett notifications@github.com wrote:

I should say that wrtc (version 0.65) works fine on Windows 10 but not Windows Server (or at east the version of Windows Server used in App Services). I could definitely get this running in a VM and/or a container but, my goal is to get this running in Azure App Services.

— 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/10#issuecomment-360866169, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7Zuk29ckhmr1CZuKdIMUy61BOqlb0ks5tOhoIgaJpZM4RusNa .

ianisms commented 6 years ago

It does make sense and really since WRTC is not a hard dependency for your project, really a non issue. I'll close it.