title: Native android app for appr.tc
body: <p>Since I few weeks I'm trying to establish a websession between a native android app (<code>https://github.com/njovy/AppRTCDemo</code>) and a browser by using apprtc. The app worked perfectly when using appr.tc as room-server url.
  I already set up the apprtc project on Ubuntu and I'm able to create a conference between a browser on the Ubuntu machine and for example the browser of my mobile device. But when I try to establish the connection between the browser on ubuntu and the app I always receive the following error: </p>
  
  <pre><code>Room IO error: java.io.IOException:
  Non-200 response when requesting 
  TURN server from https://
  networktraversal.googleapis.com/
  v1alpha/iceconfig?key=none : HTTP/
  1.1 400 Bad Request
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/x4QHw.png" rel="nofollow noreferrer">Error-Screenshot</a></p>
  
  <p>The URL mentioned in the error message is defined in src/app_engine/constants.py (<code>https://github.com/webrtc/apprtc/blob/master/src/app_engine/constants.py</code>). But I have no clue what to do with it</p>
  
  <pre><code># TODO(jansson): Remove once AppRTCDemo on iOS supports ICE_SERVER.
  TURN_BASE_URL = 'https://computeengineondemand.appspot.com'
  TURN_URL_TEMPLATE = '%s/turn?username=%s&amp;key=%s'
  CEOD_KEY = '4080218913'
  
  ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com'
  ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
  ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')
  
  CALLSTATS_PARAMS = {
    'appId': os.environ.get('CALLSTATS_APP_ID'),
    'appSecret': os.environ.get('CALLSTATS_APP_SECRET')
  }
  </code></pre>
  
  <p>So what did I do so far? (It's almost the deployment process of apprtc <code>https://github.com/webrtc/apprtc#deployment</code>)</p>
  
  <blockquote>
    <ol>
    <li>Downloaded the latest verion of apprtc from git</li>
    <li>Installed npm, nodejs and grunt</li>
    <li>Building sources by using grunt build</li>
    <li>Downloaded, installed and configured collider (collider runs on rtc:8089)
    
    <ul>
    <li>4.1  I had to change my main.go in workspace/src/collidermain <br>
    <strong>from:</strong> var roomSrv = flag.String("room-server", "hxxps://appr.tc", "The origin of the room server")<br>
    <strong>to:</strong> var roomSrv = flag.String("room-server", "hxxp://rtc", "The origin of the room server")</li>
    <li>4.2  Also changed WS_INSTANCE_HOST_KEY to colliders adresse rtc:8089 in src/app_engine/constants.py </li>
    </ul></li>
    <li>I installed CoTurn and added a turnserver.conf that looks like <br>
    listening-port=3478<br>
    listening-ip=192.168.178.20<br>
    user=rtc:webrtc<br>
    cert=/home/rtc/work/src/collider/cert/cert.pem<br>
    pkey=/home/rtc/work/src/collider/cert/key.pem</li>
    </ol>
  </blockquote>
  
  <p>Collider runs on 192.168.178.20:8089 (or rtc:8089) and the turnserver on 192.168.178.20:3478.
  Credentials defined in turnserver.conf: Username = rtc, Password = webrtc</p>
  
  <p>After the setup I added the requestIceServers-Method into src/web_app/js/util.js (<code>https://github.com/webrtc/apprtc/blob/master/src/web_app/js/util.js</code>)</p>
  
  <pre><code>function requestIceServers(iceServerRequestUrl, iceTransports) {
    return new Promise(function(resolve, reject) {
      var servers = [{
          credential: "webrtc",
          username: "rtc",
          urls: [
            "turn:192.168.178.20:3478?transport=udp",
            "turn:192.168.178.20:3478?transport=tcp"
          ]
      }];
      resolve(servers);
    });
  }
  </code></pre>
  
  <p>and commented out the standard method:</p>
  
  <pre><code>//function requestIceServers(iceServerRequestUrl, iceTransports) {
    //return new Promise(function(resolve, reject) {
      //sendAsyncUrlRequest('POST', iceServerRequestUrl).then(function(response) {
        //var iceServerRequestResponse = parseJSON(response);
        //if (!iceServerRequestResponse) {
          //reject(Error('Error parsing response JSON: ' + response));
          //return;
        //}
        //if (iceTransports !== '') {
          //filterIceServersUrls(iceServerRequestResponse, iceTransports);
        //}
        //trace('Retrieved ICE server information.');
        //resolve(iceServerRequestResponse.iceServers);
      //}).catch(function(error) {
        //reject(Error('ICE server request error: ' + error.message));
        //return;
      //});
    //});
  //}
  </code></pre>
  
  <p>When I now start my GAE, my turnserver and collider </p>
  
  <pre><code>python ~/google_appengine/dev_appserver.py ~/google_projects/apprtc-master/out/app_engine --host=0.0.0.0
  sudo turnserver -a -r 192.168.178.20
  $GOPATH/bin/collidermain -port=8089 -tls=false
  </code></pre>
  
  <p>I'm able to establish a connection between two browser clients (log from collider-terminal)</p>
  
  <pre><code>rtc@rtc:~$ $GOPATH/bin/collidermain -port=8089 -tls=false
  2016/11/05 00:07:32 Starting collider: tls = false, port = 8089, room-server=http://rtc
  2016/11/05 00:10:24 Created room stackoverflow
  2016/11/05 00:10:24 Added client 97869213 to room stackoverflow
  2016/11/05 00:10:24 Client 97869213 registered in room stackoverflow
  2016/11/05 00:10:57 Added client 96368166 to room stackoverflow
  2016/11/05 00:10:57 Client 96368166 registered in room stackoverflow
  2016/11/05 00:10:57 Sent queued messages from 97869213 to 96368166
  2016/11/05 00:11:09 Deregistered client 96368166 from room stackoverflow
  2016/11/05 00:11:09 Removed client 96368166 from room stackoverflow
  2016/11/05 00:11:19 Removing client 96368166 from room stackoverflow due to timeout
  </code></pre>
  
  <p>When I now try to connect via native app, I always receive the error mentioned above.</p>
  
  <p>After investigation I found the following link on git but it didn't help me that much: <code>https://github.com/webrtc/apprtc/issues/366</code></p>
  
  <p>So I decided to play around with the constants.py (<code>https://github.com/webrtc/apprtc/blob/master/src/app_engine/constants.py</code>) and found a place where to override the Turn/Stun server</p>
  
  <pre><code># Turn/Stun server override. This allows AppRTC to connect to turn servers
  # directly rather than retrieving them from an ICE server provider.
  TURN_SERVER_OVERRIDE = []
  # Enable by uncomment below and comment out above, then specify turn and stun
  # servers below.
  #TURN_SERVER_OVERRIDE = [
  #  {
  #    "urls": [
  #      "turn:192.168.178.20:3478?transport=udp",
  #      "turn:192.168.178.20:3478?transport=tcp"
  #    ],
  #    "username": "rtc",
  #    "credential": "webrtc"
  #  },
  #  {
  #    "urls": [
  #      "stun:stun.l.google.com:19305"
  #    ]
  #  }
  #]
  </code></pre>
  
  <p>so I commented the TURN_SERVER_OVERRIDE = [] out, commented the the other lines in and filled in the IP of my turnserver and my credentials, configured in turnserver.conf</p>
  
  <p>GAE is recognizing that there is a new request coming the app. It logs</p>
  
  <pre><code>INFO     2016-11-05 00:06:31,649 apprtc.py:408] Added client 50600142 in room stackoverflow, retries = 0
  INFO     2016-11-05 00:06:31,650 apprtc.py:92] Applying media constraints: {'video': True, 'audio': True}
  WARNING  2016-11-05 00:06:31,653 apprtc.py:136] Invalid or no value returned from memcache, using fallback: null
  INFO     2016-11-05 00:06:31,653 apprtc.py:551] User 50600142 joined room stackoverflow
  INFO     2016-11-05 00:06:31,653 apprtc.py:552] Room stackoverflow has state ['50600142']
  INFO     2016-11-05 00:06:31,658 module.py:788] default: "POST /join/stackoverflow?wstls=false HTTP/1.1" 200 1175
  </code></pre>
  
  <p>but still throws the same error.</p>
  
  <p>Since this doesn't do the trick aswell I tried to insert turn-server adresse into the ICE_SERVER_BASE_URL (still in constants.py)</p>
  
  <pre><code>ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com'
  ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
  ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')
  </code></pre>
  
  <p>Changed to</p>
  
  <pre><code>ICE_SERVER_BASE_URL = '192.168.178.20:3478'
  ICE_SERVER_URL_TEMPLATE = ''
  ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')
  </code></pre>
  
  <p>This changed the error to:</p>
  
  <pre><code>Connection error
  Non-200 response to POST to URL:
  http://rtc:8080/join/stackoverflow=wstls=false : HTTP/1.1 500 Internal 
  Server Error
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/le35a.png" rel="nofollow noreferrer">Error Screenshot 2</a></p>
  
  <p>But now I'm no longer able to open the host from a browser. Therefore I guess it's might be completly wrong.</p>
  
  <ul>
  <li>Do you got any idea how to establish a conference by using the native app?</li>
  <li>How can I bypass the networktraversal.googleapis.com URL that might
  cause the error? </li>
  <li>Do I have to bypass it?</li>
  </ul>
  
  <p>Thanks in advance!</p>