How can i start WebRTC sample application? - javascript

I've read a lot of documents about webRTC. Now I want to implement a sample application. I went through this useful stack overflow question.
And I got some client, a server in Javascript. I don't know how to start to see this demo . What are the steps should I take?
They explained like :
signaling technology: WebSockets
client: pure html/javascript
server: node.js, ws
last tested on: Firefox 40.0.2, Chrome 44.0.2403.157 m, Opera 31.0.1889.174
I understand this but I don't have much practical knowledge on this. These are my questions to setup this demo ?
Should I have a hosting account ? or can I use this with my
localhost ?
Next , where should I done this node.js, ws ? can I use with linux
machine and install npm and run the server.js file on that ?
How can I start client.js code on my Linux machine ?
Only server.js and client.js file is required to setup this
application ?

I am new with WebRTC too, but i hope my answer can satisfy you
You can use that demo in localhost
You can install nodejs in linux machine and run server.js on that.
To run the demo
run server.js through nodejs. Make sure you installed ws package first.
then you create a directory name static and put client-side code in there.
open your browser and go to localhost:80 to see the demo.
Yes, you just need 2 files to setup that application. The client file in Working Hello World WebRTC DataChannel Examples with Signaling Implemented is a html file not javascript.
You can see another tutorial in here: http://www.tutorialspoint.com/webrtc/webrtc_environment.htm
Sorry for my bad English.

Related

How to serve a REST API on Heroku

I've built a REST API that works well if I host it locally. I followed this tutorial:
http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/
How can I serve this on heroku or any other online platform so my app can execute CURL commands?
Here is the code I used:
https://github.com/taboada92/wham
Thanks
You need to add a Procfile to your project so heroku will know what to execute. If are new to Heroku + Node, I suggest going through the tutorial

Kurento Media Server HelloWorld Javascript example webSocket error

Merry Christmas!
I am trying to configure KMS on my Ubuntu 14.04 (64 bit). I could install the KMS server successfully following the guide at https://www.kurento.org/docs/6.0.0/installation_guide.html.
Also, downloaded the Javascript HelloWorld tutorial from https://www.kurento.org/docs/6.0.0/tutorials/js/tutorial-1-helloworld.html. I could run the example successfully on localhost on Google Chrome Version 47.0.2526.106 (64-bit) on the same Ubuntu System.
But, I could not see the local video nor the loop backed video. Only a spinner icon is shown on both the Video placeholders. Consulting the Console log reveals a problem after creating the SDP offer. The error is as described below.
kurento-client.js:21072 WebSocket connection to 'wss://127.0.0.1:8433/kurento' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I am no expert on web sockets and stuff. Any help on this would really help me to proceed forward.
Note: I am running the example on HTTP, not on HTTPS. I guess that would not be the cause of the problem, though.
Regards,
LazyCoder7
I managed to solve it. I was wrong on my guess though, HTTPS was indeed required in order to make the WebSocket connection ( i was not aware of that part ). Created a certificate file (.pem) (from crt and key file already in the helloworld folder) and configured the KMS server to use the certificate. After this I was able to see myself and the same me in loopback :)
You are following an old version of the documentation. Since Chrome 47, in is mandatory to server pages through HTTPS if you want to use the getUserMedia APi. So we updated all our tutorials, and they now have a self-signed certificate. In case of the JS tutorials, you also need to configure KMS to expose a secure WS signalling connection, as the browser directly connects to the media server to control it.
Please follow the latest version of the documentation here
Be sure that the KMS is running on the port 8433 (not 8888), if you are using docker
docker run -d --name kms -p 8433:8433 kurento/kurento-media-server:trusty-latest

Deploying Node JS application over a server

I have done quite a research of deploying an application over the local server that I have on my machine. Each source code for the Node JS application or the example that is available over the internet specifies to run the application from the console.
Is there any way that i can configure my MAMP server so that when i hit a URL the Node code specified is executed.
Are there any parameters to set for the same ?
I looking forward to the steps to achieve this as i was not able to found a relevant answer for the same as such.

Installing NodeJS and SocketIO in a Remote Server

My project is a Real Time Two-Player Facebook Game, and what I need is a tool that will help me build the game with quick responses to enable the "Real Time" function of the game. I have just found out about the Node JS and Socket IO. I have some knowledge in JavaScript so I stepped up and watched a few tutorials that discuss the functions of Node JS and Socket IO.
Here's the link to the videos that I have watched:
http://www.youtube.com/watch?v=mSE6xHkcX0w
I understand the basic of the Node JS and Socket IO and successfully installed it in my localhost. The problem is when I uploaded the files from my localhost to my remote server, some functions of the program are not working well. I don't know how to node my JavaScript file when it is on the server, because if it's in my localhost, I am using command prompt to run it.
node app.js
Node is not a web framework.
Chances are, you're using a web host that's generalized for web frameworks like PHP and Ruby on Rails. You're going to need virtual private server hosting, or Node-specific hosting, because Node requires a virtual machine to run. You otherwise won't be able to run Node Package Manager or Node itself.
Joyent has provided a list of hosts here.
If you chose to use a VPS or dedicated machine, an installation guide would be found here. This is how you would install Node on CentOS.
wget http://nodejs.org/dist/v<version>/node-v<version>.tar.gz
tar -zxf node-v<version>.tar.gz
cd node-v<version>
./configure
make -j <number of cores>
make install

Installing/setting up Socket.IO on my server

Ok so I have read through the Socket.IO docs and I am still a little unsure of a couple of points:
The documentation says...
To run the demo, execute the following:
git clone git://github.com/LearnBoost/Socket.IO-node.git socket.io
cd socket.io/example/
sudo node server.js
Now I don't know what this means at all! I think it may be command line interface. I of course have access to this on my localhost, but my online hosting package is a shared LAMP setup. Meaning I don't have access to the root command line (i think).
How do I actually setup socket.IO, is it impossible on my shared server package?
Appreciate any help...
W.
If you aren't familiar with node.js or with basic command line usage then I would suggest that you use a hosted WebSockets solution like pusherapp. Trying to learn WebSockets, and Node.js, and the Linux command line all at once is going to lead to a lot of frustration. Take a look a pusherapp's quick start guide, it's very easy to get started. You can have 5 simultaneous connections with a single application for free (I'm not affiliated with pusherapp).
Updated (with inline answers to questions):
If you are going to go the direction of running a Socket.IO application:
You don't technically need git since you can download node.js and Socket.IO from their respective download links on github.
You don't actually need a LAMP server to use Socket.IO. By default Socket.IO functions as a simple webserver in addition to a WebSockets server. If you want server side scripting then you might want Apache with mod_php, mod_python, etc.
You don't technically need a dedicated server or even root access. You do need a system where you can have long running process. And if you want the service to start automatically when the system is rebooted, you probably want to add a startup file to /etc/init.d, /etc/rc.d which will require root access. Both node.js and Socket.IO can be installed and run from a normal home directory. If you want to run Socket.IO on a standard port like 80 or 443 then you will need to run it with root privilege.
Node.JS scales quite well so Socket.IO will probably scale pretty well too.
It's not a simple matter to get everything setup and working, but if your goal is a free solution for web serving+WebSockets then Socket.IO is probably is good route to at least explore if you are brave.
First you'll have to determine if your host supports SSH. Sometimes they don't by default on shared hosting, but if you ask they can turn it on. If it does you'll use some sort of SSH client to connect to it. Putty for windows is the most common. Then you'll use git, which is a source control program. Which you'll probably have to install on your host, which may or may not be allowed. If you can, this can be accomplished a number of ways, you'll want to read the git documentation, it will depend largely on what linux distribution you're running. CD is change directory, basic command line stuff. sudo on the last line is telling the system to run the command as root, which it will ask you the password for, which you may not have access to on your host. Sounds like you're gonna have an uphill battle on shared hosting. You may want to opt for a VPS instead.
If your shared host is a LAMP system with no command line access you're not going to get very far with Socket.IO. The instructions you posted assume you have command line access and that you've installed the node.js runtime on your system.
If you really want to try this I recommend you get a VPS of your own (I use prgmr.com) to test it out. For what it's worth I found the Socket.IO platform pretty nice to use once I got it up and running.

Categories