WebRTC PeerConnection client nodejs - node.js

I'm trying to get WebRTC PeerConnection client on ubuntu to work with nodejs.
First I tried wrtc (https://github.com/js-platform/node-webrtc). I manage to run the client, but I cannot seem to fetch the the data stream. I've noticed the the RTCPeerConnection/PeerConnection on this module have different functions/implementation than when I run inside chrome. So I went looking for another nodejs PeerConnection.
I tried:
https://github.com/Rantanen/node-peerconnection
The already compiled version throws an error: _ZN6webrtc17BitrateController23CreateBitrateControllerEv
I figured that to get it to work properly, I have to compile the peerconnection on my machine.
I've followed http://www.webrtc.org/reference/getting-started and compile webrtc in the directory: /home/myuser/.webrtc/.
I have /home/myuser/.webrtc/trunk/out/(Debug/Release).
I have peerconnection_client executable.
Next I cloned: https://github.com/santiago/node-peerconnection (another implementation, with a make file).
When I'm trying to run the makefile (make WEBRTC_ROOT_PATH=/home/myuser/.webrtc/trunk)
I get the error:
src/node_peer_connection_client.h:9:18: fatal error: node.h: No such file or directory
include <node.h>
I have /usr/include/nodejs (and /usr/include/node symlink). I've noticed that there's an src dir inside (/usr/include/node/src/node.h).
Other things I tried:
https://github.com/js-platform/node-webrtc
https://github.com/Raynos/peer-connection
Basically, I'm trying to get a PeerConnection client that has been compiled on my machine to work with nodejs.
Any help will be appreciated ;)
Thanks

This looks promising: https://github.com/vmolsa/webrtc-native
Usage Example:
https://github.com/vmolsa/webrtc-native/blob/master/examples/node2browser/index.js:
API:
WebRTC.RTCPeerConnection
WebRTC.RTCIceCandidate
WebRTC.RTCSessionDescription
WebRTC.RTCDataChannel
WebRTC.MediaStream
WebRTC.MediaStreamTrack
WebRTC.getUserMedia
WebRTC.getSources

node-webrtc suppose to be the good choice for the time being, the project is alive. If you have any problems you should post an issue there.

Related

Twilio Video Startup

I am fairly new to React and am trying to run an example to get started with understanding how Twilio interfaces with React/Node. I am currently using the repo https://github.com/twilio/twilio-video.js, and am trying to run the test > framework > twilio-video-react, but when I npm install then npm start, the server starts, but throws the error:
Failed to compile
./src/App.js
Module not found: Can't resolve 'twilio-video'
I did `npm install twilio-video`, but still throwing error. What am I missing here? Can anyone else get this example started? I want a base example with Twilio Video working with React so I can learn from there, any other resources would help, thanks!
I tried these two examples as well, but they are outdated:
https://www.twilio.com/blog/2018/03/video-chat-react.html
https://www.twilio.com/blog/2016/03/building-a-react-powered-video-chat.html
Okay, got an example up and running with a little fudging.
I followed this example: https://www.twilio.com/blog/2018/03/video-chat-react.html
But there were a few old libraries that were causing errors.
Posted a working version on my Github linked here.

The lightest possible nodejs build

I'm trying to run a small nodejs project on a old router (A part of a challenge) but have ran into problems, as it only has about 6MB of usable memory. First off I ran the build through upx that took the build down to around 6mb. After that I tried using older builds iojs and v1.01. They worked fine except that they lacked features required to run the ws module (the other part of the challenge). After that I ran ./configure with the arguments of --without-dtrace --without-npm --without-etw --without-perfctr --with-icu-source=none but they still refused to bring down the build size. Is there a way to build nodejs in such a way that it runs the ws module and has an output that's under 6MB
Due to memory issue I think this will not work in your case.
Try this one espruino . Here You can read more detally
You should try CivetWeb: https://github.com/civetweb/civetweb It include Websocket and support javascript via Duktape.

Installing a Web Server for Node.js

I'm trying to follow a book I purchased called "Pro Angular JS", and I am having trouble getting a web server pointed to the right port. So I go to the command line, run Node, and the first error I get is this, when trying to install connect:
npm should be run outside of the node repl, in your normal shell.
(Press Control-D to exit.)
Ok, fair enough. So I do as the command specifies, and I get it to install just as the user, and it ends up adding a folder called node_modules in my user root folder. Ok, seems like everything still makes sense.
Now, the book tells me to create a server.js file within the Node.js installation folder. There is no Node.js installation folder actually created on my user. I see the node_modules folder for sure. So I'm guessing the root directory of my user is where node.js was installed but maybe it's hidden or something? I believe when I used the Mac installer for Node, it said it was created at usr/local/bin. But I have no idea if that is my user on my computer, or even more root access to my computer.
Lastly, back to this server.js file...so I created it with a text editor, containing this code:
var connect = require('connect');
connect.createServer(
connect.static(".../angularjs")
).listen(5000);
And of course they want me to add this file to the directory where my Node is installed. Currently, it's sitting where my current user (user is kst001) root directory is. This is also where my node_module folder was created when I installed it using the npm install connect line in the shell. They also wanted me to create a folder called angularjs, where I would store my app, and said to place it in the root directory where node.js was installed. Once again, sitting in the root directory with everything else. Yet, when I try and fire up my test document in port 5000 (localhost:5000/test.html), I get a "could not find page" error.
Already tried using this link to solve my problem, which seems dead on for my issue, but it resolved nothing:
Node / connect issue Object function createServer has no method static
I'm using a Mac, by the way. Any ideas, guys? Any help would be much appreciated.
The reason why connect.static() does not work is that the latest major version of connect (3.x) no longer contains all of the middleware that connect was bundled with in 2.x.
The readme for connect has a list of middleware references that show you the name of the module on npm that gives you the old functionality for each middleware (e.g. static is now broken out into its own module serve-static).
I'm following the same book/example and the following works. I claim no credit, it is from another Stack Overflow answer about setting up a simple server plus the contents of a comment on the same answer (question 24346161 link to it from here: nodejs connect cannot find static)
Because I used it in exactly the same learning context (book I also purchased called "Pro Angular JS") and I have been around the houses for 3 hours trying to sort this out (yes a complete novice), I thought I would post it here.
firstly from your node installation directory
npm install serve-static
secondly, your node server.js code for a simple static server to serve your angularjs directory contents in a localhost:5000 browser window, on a Windows 7 machine should be (as at July 2015) ...
var connect = require('connect'),
serveStatic = require('serve-static');
var app = connect();
app.use(serveStatic("./angularjs"));
app.listen(5000);
I just stuck a simple index.html file in the angularjs directory to begin with containing
connection working
to test it and it worked a treat.

How do I make serialport work with node-webkit

I need serialport to work with node-webkit. I already have serialport.node but I don't know how to make it work. I always get the same error: "Uncaught error: Cannot find module serialport" and tried it in versions 0.6.3 and 0.5.0.
Thank you!
node-webkit support all the nodejs apis and all its third party modules.
so you can get serialport from serialport just like other packages of nodejs, and follow the instructions the page said. it should work fine after you install serialport.
If something is wrong with the version of your serialport.node, you can see the issue, someone has compiled it successfully. You may want to try it.
You will need to build it with nw-gyp.

Including socket.io.js results in undefined 'require'

I've just started with node.js and socket.io.
I installed node.js using the windows installer, resulting in the following install path:
C:\Program Files (x86)\nodejs
I used npm to install socket.io and managed to include this in my server file, which is located in my projects folder, under
D:\projects\node\nodeserv.js
I then included the socket.io.js, which is located under the same socket.io folder, under the nodjs folder.
However, when I try to open the HTML file containing the client code, I get an error in socket.io.js stating:
Undefined reference to 'require'
Can someone help me out and see what I am doing wrong?
Make sure to check your spelling very carefully. If you can post post some code to look at, we can probably tell you the problem right away. More than likely it's a simple typo.
It sounds like you are trying to run node.js from the browser. Node.js runs on the server with the node executable. When you open the HTML file in your browser, it will execute the Javascript on it in a non node.js environment.
Apparently you need to get the socket.io.js file from the nodejs server.
So instead of an include, use an async call to get the file, like:
$.getScript('http://localhost:1337/socket.io/socket.io.js', function(){
//You can now use the io namespace
});

Resources