Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Android - self._wrtc.RTCPeerConnection is not a constructor #15

Closed
d3b00 opened this Issue Apr 9, 2018 · 18 comments

Comments

Projects
None yet
2 participants
@d3b00
Copy link

d3b00 commented Apr 9, 2018

No description provided.

@d3b00 d3b00 changed the title Error - self._wrtc.RTCPeerConnection is not a constructor E Apr 9, 2018

@contra contra closed this Apr 9, 2018

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

Works on Windows.

But when I try to run in Android:
supported: false
error: self._wrtc.RTCPeerConnection is not a constructor
both in actual phone and emulator.

@d3b00 d3b00 changed the title E Error in Android - self._wrtc.RTCPeerConnection is not a constructor Apr 9, 2018

@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

I closed this because it was an empty ticket with just the letter "E" as the title, but you edited it to add info so I'll reopen.

@contra contra reopened this Apr 9, 2018

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

Yeah I did that by mistake.
What about the issue though, is rtc-everywhere not supported in android?

@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

@d3b00 Should work fine on android, will look into it. Can you post the code you're using?

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

Node.js is embedded in my android app and whenever I try to create a peer I get this error

@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

@d3b00 Yep I need to see your code, it sounds like the issue is with the usage and not rtc-everywhere itself.

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

this is my code:

const rtc = require('rtc-everywhere')();
const Peer = require('simple-peer');

console.log(rtc.supported); // prints false on Android and true on Windows

const p1 = new Peer({ wrtc: rtc, initiator: true });

And this is the error:
/files/nodejs-project/node_modules/simple-peer/index.js:82
self._pc = new (self._wrtc.RTCPeerConnection)(self.config, self.constraints)
^

TypeError: self._wrtc.RTCPeerConnection is not a constructor
at new Peer (/files/nodejs-project/node_modules/simple-peer/index.js:82:14)
at Object. (/files/nodejs-project/abc.js:6:12)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:611:3

@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

@d3b00 If you log the rtc object what does it show?

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

In Android

{ 
      platform: 'node',
      supported: false,
      getUserMedia: [Function],
      RTCPeerConnection: undefined,
      RTCSessionDescription: undefined,
      RTCIceCandidate: undefined,
      attachStream: [Function] 
}

On Windows

{ 
  platform: 'node',
  supported: true,
  getUserMedia: [Function],
  RTCPeerConnection: [Function: RTCPeerConnection],
  RTCSessionDescription: [Function: RTCSessionDescription],
  RTCIceCandidate: [Function: RTCIceCandidate],
  attachStream: [Function] 
}
@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

This is in an android emulator? Interesting, so it looks like the bug is that its identifying your emulator as node and then failing to load the node library because that is node-specific.

@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

Is this in cordova or some other framework? What does typeof window log?

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

well but that is the expected behavior. It should be treated like Node. As I said "Node.js is embedded in my android app" and I am running it in that embedded Node.js and all my other files where I have imported other modules like async, md5, etc are working fine so I guess Node.js is correctly configured.

@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

Ah I see the issue - you need to install the wrtc module. Documented here: https://github.com/contra/rtc-everywhere#other

Let me know if that doesn't work and I'll reopen.

@contra contra closed this Apr 9, 2018

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

wrtc is already installed. I was working with wrtc and simple-peer when I was not using WebRTC on Android but now I need it to work on Android and wrtc only supports x64 architecture that's why I installed rtc-everywhere.

But yeah, wrtc is already installed.

@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

@d3b00 rtc-everywhere uses wrtc for the webrtc bindings for node. If wrtc directly doesn't work for you then neither will rtc-everywhere - sorry. As far as I know wrtc is the only node binding available.

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

but I think wrtc is not working because it doesn't support Android architecture. Isn't rtc-everywhere specifically built to provide support for incompatible architectures/environments?

contra added a commit that referenced this issue Apr 9, 2018

@contra

This comment has been minimized.

Copy link
Owner

contra commented Apr 9, 2018

@d3b00 rtc-everywhere exists to provide a nice abstraction/normalization across JS environments (and libraries), so one codebase will work everywhere regardless of the browser or mobile JS framework. Our target was never non-JS apps. If you have issues with node-webrtc not working on your environment you should open a ticket on that repository.

If you're building a native android app you would be better off using the standard java webrtc bindings than embedding node and using rtc-everywhere. I've updated our docs to reflect the limitations of the wrtc module.

@d3b00

This comment has been minimized.

Copy link
Author

d3b00 commented Apr 9, 2018

Well you're probably right, should use java webrtc bindings.
thanks for your time tho 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.