Open louptheron opened 8 years ago
looks like the second line is actually
var portcontrol = freedom.freedom('node_modules/freedom-port-control/dist/port-control.json');
it give me no error, but when I test :
var freedom = require('freedom-for-node');
var portcontrol = freedom.freedom('node_modules/freedom-port-control/dist/port-control.json');
portcontrol.probeProtocolSupport();
there is
TypeError: portcontrol.probeProtocolSupport is not a function
Result of a console.log(portcontrol)
:
lib$es6$promise$promise$$Promise {
_id: 0,
_state: undefined,
_result: undefined,
_subscribers: [] }
you probably have a promise that resolves to the expected interface. Sorry - all of the calls will be asynchronous promises, rather than direct returns.
var freedom = require('freedom-for-node');
freedom('node_modules/freedom-port-control/dist/port-control.json').then(function(portControl) {
return portControl.probeProtocolSupport();
}).then(function(support) {
console.log(support);
});
Ok, I followed the code example and the freedom-port-control
module is loaded (got it for the promise, thank you) :
require('freedom-for-node').freedom('node_modules/freedom-port-control/dist/port-control.json', {}).then(function(Root){
var root = new Root();
root.probeProtocolSupport().then(function(res){
console.log(res);
});
});
but I got new errors :
Cannot instantiate provider, since it is not provided
[unbound Provider] dropping message {"to":8,"type":"message","message":{"action":"method","type":"createDataChannel","reqId":0,"text":["dummy data channel",null],"binary":[]}}
Cannot instantiate provider, since it is not provided
[unbound Provider] dropping message {"to":9,"type":"message","message":{"action":"method","type":"createDataChannel","reqId":0,"text":["dummy data channel",null],"binary":[]}}
[unbound Provider] dropping message {"to":8,"type":"message","message":{"action":"method","type":"close","reqId":1,"text":[],"binary":[]}}
[unbound Provider] dropping message {"to":9,"type":"message","message":{"action":"method","type":"close","reqId":1,"text":[],"binary":[]}}
UPnP failed at: URL is not defined
It seems that _getUpnpControlUrl()
does not give the expected controlUrl as expected, maybe with a bad Ssdp response.
Sigh. Didn't realize this code had a dependency on WebRTC - probably to learn your external IP address through the STUN process.
I don't think i've ever made that work in a reliable way in node.js, although that's probably worth doing. The alternative is to not use STUN, or use it as a UDP protocol rather than bundled in webRTC.
Mhm ok, thank you for your help !
Actually, I think this error is because we're using the URL interface that's only supported in Chrome or Firefox, and not in node. This was fine since our initial use case was only in browser apps.
From a quick look, it seems like URL
is only used on one line here, so it should be fairly easy to substitute out and remove this dependency.
Also, if I recall correctly, WebRTC is only used to determine the private IPs of the computer, which is done by gathering ICE candidates on a dummy data channel – no STUN servers are actually used.
Yeah, it looks like there will be minor incompatibilities with the current code and node. @willscott what do you think is the best way to deal with this?
If you need XMLHttpRequest in a freedom module, you might like https://github.com/uproxy/freedom-xhr
After a successful
npm install freedom-port-control
andnpm install freedom-for-node
, running :give me an error :
TypeError: freedom is not a function
Running :
var portcontrol = freedom.freedom('node_modules/freedom-port-control/src/port-control.json');
I have this error :
[ReferenceError: require is not defined]
Do you know why ?
Thank you