2

I have ApprtcDemo from Android to Desktop not working, i have followed all the StackOVerflow links and Google discussion links none of them made it working yet, everybody claim that local setup worked for them but doing the same suggestion did not worked.

So please here you can find the completely source code how others did and i also did but still when Android device app starts i can only see selfview and it connects to Google Apps Engine but it never connects to the room for a audio/video session.

Can you please suggest and advise so that we can together make a reliable answer here about this issue? it took me 3 months and i could not make it work yet.

Step 1: go to https://code.google.com/p/test-apprtc-demo/source/browse/

Step 2: folder apprtc = javascript, python, webrtc, google app engine complete code folder android contain all the source code of android apprtcdemo

Step 3: please check those files which i modified

a) https://code.google.com/p/test-apprtc-demo/source/browse/android/assets/channel.html

here i have embedded the javascript where others were confusing about it

https://code.google.com/p/test-apprtc-demo/source/browse/apprtc/index.html

here i have changed the pcConfig variable with hardcoded turnserver details

b) https://code.google.com/p/test-apprtc-demo/source/browse/android/src/org/appspot/apprtc/AppRTCClient.java

here i have modified private PeerConnection.IceServer requestTurnServer(String url) private LinkedList iceServersFromPCConfigJSON( String pcConfig)

c) https://code.google.com/p/test-apprtc-demo/source/browse/android/src/org/appspot/apprtc/AppRTCDemoActivity.java

here i have modified roomInput.setText("http://notappspot.com.placeit.toyour.localhost/?r=");

d) https://code.google.com/p/test-apprtc-demo/source/browse/android/src/org/appspot/apprtc/GAEChannelClient.java

here i have modified nothing webView.loadUrl("file:///android_asset/channel.html"); //<< no need to change cause we have channel.html file with javascript embedded check that file

Step 4: now the Apprtcdemo was build/release and ran in my Android phone , at the same time i was in my WebRTC server connected with Google Chrome latest version

Step 5: when Android and Google Chrome try to connect nothing happens Google chrome shows "waiting for someone to join...."

and on Android i have a Green screen and my own camera view on top right corner.

Please please kindly someone advise. so that i can make this interconnect i lost 3 month on this.

EDIT:

Step 1: start the local server for signaling to allow Mobile and Google Chrome do shake hand:

$ python dev_appserver.py --host 0.0.0.0 --port 9999 /var/tmp/webrtc-read-only/samples/js/apprtc
WARNING  2014-05-30 08:07:49,416 api_server.py:378] Could not initialize images API; you are likely missing the Python "PIL" module.
WARNING  2014-05-30 08:07:49,420 simple_search_stub.py:1072] Could not read search indexes from /var/folders/h3/jgrrj7fd35vf0v77xjbhryph0000gn/T/appengine.apprtc.sun/search_indexes
INFO     2014-05-30 08:07:49,424 api_server.py:171] Starting API server at: http://localhost:52919
INFO     2014-05-30 08:07:49,427 dispatcher.py:182] Starting module "default" running at: http://0.0.0.0:9999
INFO     2014-05-30 08:07:49,434 admin_server.py:117] Starting admin server at: http://localhost:8000

Step 2: launch PC Google Chrome to connect the server

<<<<========= PC Google Chrome Browser connnected and waiting for someone to join ====>>>

INFO     2014-05-30 08:09:34,059 apprtc.py:147] Applying media constraints: {'video': True, 'audio': True}
INFO     2014-05-30 08:09:34,070 apprtc.py:473] User 24910306 added to room 12344
INFO     2014-05-30 08:09:34,070 apprtc.py:474] Room 12344 has state [24910306-False]
INFO     2014-05-30 08:09:34,075 module.py:639] default: "GET /?r=12344 HTTP/1.1" 200 1646
INFO     2014-05-30 08:09:34,123 module.py:639] default: "GET /js/adapter.js HTTP/1.1" 304 -
INFO     2014-05-30 08:09:34,123 module.py:639] default: "GET /css/main.css HTTP/1.1" 304 -
INFO     2014-05-30 08:09:34,124 module.py:639] default: "GET /js/main.js HTTP/1.1" 304 -
INFO     2014-05-30 08:09:34,289 apprtc.py:268] User 24910306 connected to room 12344
INFO     2014-05-30 08:09:34,290 apprtc.py:269] Room 12344 has state [24910306-True]
INFO     2014-05-30 08:09:34,366 module.py:639] default: "POST /_ah/channel/connected/ HTTP/1.1" 200 -
INFO     2014-05-30 08:09:34,379 module.py:639] default: "GET /favicon.ico HTTP/1.1" 404 154

At that time Google chrome browser log:

This appears to be Chrome
Initializing; room=12344.
Opening channel.
Requested access to local media with mediaConstraints:
  '{"video":true,"audio":true}'
Channel opened.
User has granted access to local media.

Step 3: Open Android Apps

<<<<======== Now opening Android phone AppRTCDEmo executed to connect with above Google Chrome, but nothing more happens ======>>>

INFO     2014-05-30 08:11:54,693 apprtc.py:147] Applying media constraints: {'video': True, 'audio': True}
INFO     2014-05-30 08:11:54,693 apprtc.py:473] User 28334488 added to room 12344
INFO     2014-05-30 08:11:54,693 apprtc.py:474] Room 12344 has state [24910306-True, 28334488-False]
INFO     2014-05-30 08:11:54,698 module.py:639] default: "GET /?r=12344 HTTP/1.1" 200 1652

Step 4: nothing happens

Now nothing happens..... and please see mobile and desktop screen shot, both are doing nothing like its waiting for something....

enter image description here enter image description here

  • 2
    What if you first verify if this works between 2 browsers and 2 phones? And what if you add some logging to all the functions being executed (so you can exactly see what is going wrong, as I expect the code is not doing something but which part I have no idea). – MarijnS95 May 30 '14 at 07:47
  • 1
    For instance, when looking at the browser side [javascript code](https://code.google.com/p/test-apprtc-demo/source/browse/apprtc/js/main.js), I see it logs a whole bunch of stuff. If you can copy paste that here would make it a lot easier. – MarijnS95 May 30 '14 at 07:49
  • 1
    Nope, I want the browser side logs it generates. This way we can see if there is something missing in the establishment of the session. And if you have server log that might come in handy too, as I think it is related to missing some information/not having enough ICE candidates. – MarijnS95 May 30 '14 at 08:05
  • 1
    And your info div thingy seems to show stuff. Is there a difference between what it shows when you successfully establish a connection and when you don't? – MarijnS95 May 30 '14 at 08:08
  • 1
    Aha, it seems like the phone application is not doing something. If you can compare the logs of a working connection (pc <--> pc) you might figure out what misses. Especially the content of the `"POST /_ah/channel/connected/ HTTP/1.1" 200` as I do not see that line appear when the phone connects (so it basically misses out something there) – MarijnS95 May 30 '14 at 09:02
  • 1
    Yes, you can of course send an ajax request, and then just add a parameter to it. In javascript do it like so: `xhr = new XMLHttpRequest(); xhr.open('GET', 'http://yoururl/somepath?yourparameteryouwanttocheck=true'); xhr.send()` – MarijnS95 May 30 '14 at 12:53
  • 1
    If it is a local net work connection, Ice candidates do not matter at all, so do not worry about that part. Your SDPs are not being exchanged and set, that is why it is not working. Do your logs show what media is passing through the signalling server to see the SDPs? – Benjamin Trent May 30 '14 at 13:00
  • @bwtrent: its in local network 192.168.1.11 is the server, Android mobile is 192.168.1.21 and PC with Google chrome is 192.168.1.11. SDP's i never saw getting generated in Google Chrome nor in Android. How do i make both get SDP started? –  Jun 02 '14 at 06:18
  • 1
    Okay, according to the logs the function `maybeStart` breaks somewhere. There is an if which I suspect is not firing because not all requirements are met. Now, I want you to log these. I added it to your code in the google-code system, but you can also inster this in the function `maybeStart`, directly the first line: `console.trace(); console.log('started?', started, 'signalingReady', signalingReady, 'channelReady', channelReady, 'turnDone', turnDone, 'localStream', localStream, 'hasLocalStream', hasLocalStream);` Then try to set up a connection and show me the results. – MarijnS95 Jun 02 '14 at 08:29
  • http://paste.ubuntu.com/7571818/ - I did like you suggested please see the attached paste of result. its still same, connection did not happen yet. –  Jun 02 '14 at 09:30
  • @MarijnS95: to temporary make connection at-least work, do you suggest we should temporary avoid using this: `if (!started && signalingReady && channelReady && turnDone && (localStream || !hasLocalStream))` into `if (!started && signalingReady && channelReady && (localStream || !hasLocalStream))` ? avoid the Trun checkup? –  Jun 02 '14 at 12:17

1 Answers1

3

After a lot of discussion, trial, error and logging we come tho these answers to fix the problems:

  1. Do not load channel.html from the internal assets folder. Then the url's don't match up anymore. (It is trying to post a message to the server at 'file://'+'/_ah/channel/jsapi', instead of 'http://server_adress:port'+'/_ah/channel/jsapi')
  2. After fixing that there was a problem with double slashes. appRTCSignalingParameters.gaeBaseHref contained a slash on the end, but appRTCSignalingParameters.postMessageUrl did that on the beginning so the program tried to post to server_adress:port//message which is incorrect. Simply removing the / from appRTCSignalingParameters.postMessageUrl fixed this.

Old answer:
Thanks for the logging. Now we know what goes wrong. The if doesn't trigger because signalingReady == 0. The reason it is zero is because of something I found on line 49:

// Caller is always ready to create peerConnection.
signalingReady = initiator;

I have no idea why this is there, and what it does.

Also, the only way to make it true happens on line 311, which is inside the function onChannelMessage. There is no log from that function, and also the console.trace doesn't show anything from onChannelMessage, as right on line 312 it should call maybeStart(). So to temporary avoid it won't work, because there is no signalling done.

So what I think would solve the solution is to set initiator to 1 somewhere. You can do this for instance in the function that creates a new room, so the script directly knows that you are the initiator and not joining anyone.

I hope this solves your problem, and please keep me updated on further results and problems.

(As this is a demo from the site, I also suggest you to try and understand how an RTC connection is established, and write everything from the ground up. This will make your knowledge a lot better and debugging will be much easier, as it is your own code which you understand).

MarijnS95
  • 4,703
  • 3
  • 23
  • 47
  • Oh! I follow your instruction and the `appRTCSignalingParameters.gaeBaseHref` did happen to be ended with 2 slashes which make the POST failed. BTW I didn't setup STUN server for testing them locally. So what if I want to deploy it to the internet? Would it just find other `existing` STUN/TURN server to make it work? Or I need to setup my own stun/turn server? – Robert Sep 04 '14 at 03:13
  • @Robert you can do both. You can use [public servers](http://stackoverflow.com/questions/20068944/webrtc-stun-stun-l-google-com19302) but also create your own. But you need to tell the browser which to use: `x = new RTCPeerConnection({'iceServers': [{'url': 'stun:stunserver1.com'}, {'url': 'stun:stunserver2.com'}]})`. – MarijnS95 Sep 05 '14 at 16:18