WebRTC APPRTC (i) Environmental configuration detailed steps and pit summary

Source: Internet
Author: User
Tags hmac sha1 ssl connection

WebRTC really is not very good to get, currently only the PC-side web page and mobile phone-side web page video. But there are still some problems. 1, both must use Firefox 2, feel pc-side camera shot out of the screen can also, the phone side a little bit of spending 3, enter the room after a period of time to show two video ~~~~APPRTC demo has not been tuned, the problem in Turnserver , and then sent the article. There are a lot of APPRTC on the Internet, some of the details are not detailed, anyway, there are a lot of holes in the middle.

(PS: This picture draws the wind to look more and more strange)

Before the article was configured, but also for everyone as a reference. Step I'll write it again.
http://blog.csdn.net/s569646547/article/details/50780682

Prepare

Prerequisites: Ubuntu is installed in the VM under window. Ubuntu Don't use 16.04! 16.04 unstable and the network is a big pit pit! Ubuntu Network connection Select Bridge connection. The bridge connection is equivalent to your current Ubuntu as a standalone host in the local area network so that other hosts can access it.
The permissions allowed by the VM bridging mode of the host are opened first.



Then according to the following image or URL in the way to set their own static IP, you can first ifconfig command to see their own IP (important in the back so here is not wordy)

Http://www.cnblogs.com/vincedotnet/p/4013099.html
You also need to shut down the VM's firewall ufw disable and your computer's firewall.
Prerequisite Preparation:
1, install Vmware-tools, for Windows and VM files, text copy.

2, the installation of the JDK after the command will be involved (step (3), (4), then it seems to be executed first (1), (2) but no successful installation, with (3), (4) The command line is simple to install it)
(1) Go to the official website to download the JDK i downloaded jdk-8u121-linux-x64.tar.gz
Http://www.oracle.com/technetwork/java/javase/downloads/index.html
(2) Find your download folder
Find the files you downloaded and unzip them.

file.name

After decompression use root permissions sudo -i and then find your download directory, cd /home/ubuntu/download (my user name for Ubuntu, where the path is replaced by their own) and then the extracted JDK files moved to the new directory, the mkdir jdk1.8.21 /usr/java following, and then modify the file name mv jdk1.8.21 java-8-sun
Next, configure the JDK environment, use the terminal input sudo vi/etc/profile edit profile, press I, at the last input

#set java environmentJAVA_HOME=/usr/java/java-7-sunexport JRE_HOME=/usr/java/java-7-sun/jreexport CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

Press the ESC key and then press the colon key to enter WQ to save.
(3) Finally, enter the java-version command to test the JDK version and view the JDK version.
(4) If the version number of the JDK does not appear, try the command line to install the JDK again.

sudo apt-cache search openjdksudo apt-get updatesudo apt-get install openjdk-8-jdk

If not, you can follow this article to get a bit.
http://blog.csdn.net/y999666/article/details/51685761
3, lantern need to turn over the wall, after downloading directly double-click to run the installation.
http://download.csdn.net/detail/danfengw/9801021
4.

Action three servers

Room servers, signaling servers, penetrating servers

1, APPRTC Room server HTTPS://GITHUB.COM/WEBRTC/APPRTC

2, Collider signaling server above the source code in the own

3. Coturn Penetrating server Https://github.com/coturn/coturn

4, need to implement their own Coturn connection information interface, the main return user name, password and turn configuration information, usually called Turn REST API, do not implement this interface Apprtcdemo not connected to the server, browser access can be normal access.

APPRTC Room Server
  1、下载代码  2、安装依赖    
sudo apt-get-g npmsudo apt-get install nodejs-legacy-g install grunt-cli

Switch to source directory

cd apprtcnpm installsudo apt-get install python-webtest(之前是大写p安装不上)grunt build(需要root权限 `sudo -i`再进入文件夹运行该命令)

After compiling, the out directory is more
Run also relies on Google App Engine SDK for Python to flip the wall
Do not download the wrong here, I then downloaded the wrong thought that I want to download Gclund wasted some time. Find the blue words clicked after Python clicked on the page jump.

Set environment variables after download

      sudo gedit /etc/profile      PATH=$PATH:/home/google_appengine      source /etc/profile

3. Modify the configuration file

ifconfigView your IP, modify the configuration is primarily the apprtc.py and constants.py in the Src/app_engine directory

The first is constants.py:

Modify Turn_base_url = ' http://192.168.1.107:80 ' This is the address of the connection information interface mentioned above

Turn_url_template= '%s/turn. php?username=%s&key=%s 'Ceod_key=and Coturn Turnserver.conf static-auth-secretConsistent wss_instances= [{wss_instance_host_key:' 192.168.214.129:8089 ', Wss_instance_name_key:' WSSERVER-STD ', Wss_instance_zone_key:' us-central1-a '}, {wss_instance_host_key:' 192.168.214.129:8089 ', Wss_instance_name_key:' Wsserver-std-2 ', Wss_instance_zone_key:' Us-central1-f '}]

apprtc.py:
Modify the Get_wss_parameters (request) under

  ifand‘false‘:  ‘ws://‘‘/ws‘  ‘http://‘ + wss_host_port_pair  else:  ‘ws://‘‘/ws‘  ‘http://‘ + wss_host_port_pair

The main thing is to change the original WSS and HTTPS scheme to WS and HTTP, do not let the client and the browser to use SSL connection, if there is a third-party root certificate issued by the signing Authority certificate is not required.
After the modification, grunt build again.

4, start (as long as the download of the Google_appengine this sentence should be able to carry out the past)

dev_appserver.py–host=0.0.0.0./out/app_engine

Collider Signaling Server

This part's going to be okay, just step by step.
1. Installation dependent

     sudo apt-get install golang-go(之前那篇文章是大写G,安装不上)

2. Create a folder at home

   mkdir -p ~/collider_root        并在collider_root目录下创建src目录

Set GOPATH environment variable export gopath=~/collider_root

Copy all three folders under the Apprtc/src/collider directory to COLLIDER_ROOT/SRC

Go to COLLIDER_ROOT/SRC, start compiling and installing collider, ready to turn the wall.

     go get collidermain     go install collidermain

After successful compilation, the bin and pkg directories are generated under the Collider_root directory, and the files are executed under the bin.

3. Operation

Modify Collider_root/src/collidermain/main.go fill in your own IP address

      var roomSrv = flag.String("room-server", "http://192.168.1.107:8080/", "The origin of the room server")

Start

      ~/collider_root/bin/collidermain -port=8089 -tls=false
Coturn Hole-Punching server

1. Download http://turnserver.open-sys.org/downloads/

Find a suitable Linux system, I here is ubuntu32 bit so chose turnserver-4.2.1.2-debian-wheezy-ubuntu-mint-x86-32bits.tar.gz

After downloading, unzip into the extract directory

      cat INSTALL     查看安装须知      sudo apt-get install gdebi-core      sudo gdebi coturn_4.2.2.2-1_i386.deb

2. Edit the configuration file

       sudo gedit /etc/turnserver.conf       listening-device=eth0       listening-port=3478       relay-device=eth1       min-port=49152       max-port=65535       Verbose       fingerprint       lt-cred-mech       use-auth-secret       static-auth-secret=填写自己的密钥可不修改       stale-nonce       cert=/usr/local/etc/turn_server_cert.pem       pkey=/usr/local/etc/turn_server_pkey.pem       no-loopback-peers       no-multicast-peers       mobility       no-cli

3. Generate a signing certificate

       sudo openssl req -x509 -newkey  rsa:2048 -keyout/usr/local/etc/turn_server_pkey.pem -out /usr/local/etc/turn_server_cert.pem -days 99999 -nodes       

4. Start

      service coturn start
Coturn Connection Information interface

Use Nginx to deploy the PHP page
1. Installing Nginx

apt-get install nginx

2. Start Nginx

start

3. Accessing the server IP
If you see "Welcome to Nginx!" The instructions are ready to install.
4. Install PHP

apt-get install php7

5. Configure Nginx

vi /etc/nginx/sites-available/default

Locate the following code, and remove the corresponding comment

location ~ \.php$ {        include snippets/fastcgi-php.conf;        fastcgi_pass unix:/var/run/php7-fpm.sock;}

Restart Service

service nginx restart

6. The default Web site root directory is in/var/www/html

vi /var/www/html/test.php

Enter the following and save

<?php      $request _username=$_get["username"];if(Empty($request _username)) {Echo "username = = NULL";Exit; }$request _key=$_get["Key"];$time _to_live= -;$timestamp= Time () +$time _to_live;//Expiry time    $response _username=$timestamp.":".$_get["username"];$response _key=$request _key;if(Empty($response _key))$response _key="Key";//constants.py in Ceod_key 408 ...    $response _password= Getsignature ($response _username,$response _key);$JSONOBJ=NewResponse ();$JSONOBJ->username =$response _username;$JSONOBJ->password =$response _password;$JSONOBJ->ttl =86400;$JSONOBJ->uris =Array("TURN:192.168.1.107:3478?TRANSPORT=UDP","Turn:192.168.1.107:3478?transport=tcp","TURN:192.168.1.107:3479?TRANSPORT=UDP","Turn:192.168.21.107:3479?transport=tcp");EchoJson_encode ($JSONOBJ);/** * Generate signature value using HMAC-SHA1 algorithm * * @param $str Source String * @param $key key * * @return Signature value */         function getsignature($str, $key) {            $signature="";if(Function_exists (' Hash_hmac ')) {$signature= Base64_encode (Hash_hmac ("SHA1",$str,$key,true)); }Else{$blocksize= -;$hashfunc=' SHA1 ';if(Strlen ($key) >$blocksize) {$key= Pack (' h* ',$hashfunc($key)); }$key= Str_pad ($key,$blocksize, Chr (0x00));$ipad= Str_repeat (Chr (0x36),$blocksize);$opad= Str_repeat (Chr (0x5c),$blocksize);$hmac= Pack (' h* ',$hashfunc(                                ($key^$opad) . Pack' h* ',$hashfunc(                                                ($key^$ipad) .$str)                                )                        )                );$signature= Base64_encode ($hmac); }return $signature; } class Response {           Public $username=""; Public $password=""; Public $ttl=""; Public $uris=Array(""); }?>  
Test
   部署成功后可在浏览器输入http://192.168.1.107:8080创建房间   appRTCDemo连接也改成http://192.168.1.107:8080即可

Add

The following seems to be a problem in the middle, forget what is the problem, just add it here
1. Open the webpage, copy the setuptools download link, download the installation package with wget

wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e

2. Unzip the downloaded setuptools-0.6c11.tar.gz

tar -zxvf setuptools-0.6c11.tar.gz

3. Enter the setuptools-0.6c11.tar.gz source file and use the executable command of the installed Python to perform the Setuptools installation
(1) Compiling

python2.7 setup.py build

(2) Installation

python2.7 setup.py install

http://blog.csdn.net/s569646547/article/details/50780682

sudo apt-get install openjdk-8-jre-headless

Gclound not found command: Restart VM

WebRTC APPRTC (i) Environmental configuration detailed steps and pit summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.