catchpoint / WebPageTest.agent

Cross-platform WebPageTest agent
Other
213 stars 138 forks source link

Android - SimpleRT needs working WiFi connection once after reboot #55

Open sburnicki opened 7 years ago

sburnicki commented 7 years ago

Hey, with our Samsung Galaxy S7 we experience an issue with reverse tethering. When the phone is restarted, Chrome throws an ERR_INTERNET_DISCONNECTED, although we can execute ping commands via adb shell. We need to connect and disconnect the phone to a WiFi once after every reboot in order to have a working connection with Chrome.

Do you experience similar issues or know a workaround?

pmeenan commented 7 years ago

All of my devices are also connected to WiFi to trigger anything that may look for it (or cell) to think the OS has connectivity. I leave them connected 100% of the time and the SimpleRT tunneling takes over the default route so nothing actually goes over WiFi (and the SimpleRT device check makes sure the tun interface is up so in a failure mode it won't accept tests).

FWIW, if I can get tethering to work on iOS it is going to have the same issue. The VPN interface on iOS refuses to start if it doesn't have an active network connection.

sburnicki commented 7 years ago

Great, thanks for the tip, we will try that. Another issue we're facing is that the simpleRT process blocks the wptagent execution:

12:55:23.809 - Default interface: eth0
RTNETLINK answers: File exists
RTNETLINK answers: No such file or directory
12:55:24.006 - adb devices
12:55:24.022 - List of devices attached
ce07171763ceac840d    device

12:55:24.133 - adb shell am force-stop com.viper.simplert
12:55:24.764 - Starting simple-rt bridge process
Running agent, hit Ctrl+C to exit
12:55:24.772 - adb shell input keyevent 25
starting network
configuring:
local interface: eth0
virtual interface: tun0
network: 10.1.1.0
address: 10.1.1.1
netmask: 24
nameserver: 8.8.8.8
tun0 interface configured!
SimpleRT started!
12:55:25.644 - adb shell su -c service call notification 1
12:55:25.700 - adb shell dumpsys package com.samsung.android.MtpApplication | grep versionName
12:55:25.795 -     versionName=1.0

12:55:25.797 - adb shell am force-stop com.samsung.android.MtpApplication
12:55:26.449 - adb shell dumpsys package com.google.android.apps.docs | grep versionName
12:55:26.536 -     versionName=2.7.063.14.46

12:55:26.538 - adb shell am force-stop com.google.android.apps.docs
12:55:27.174 - adb shell dumpsys package com.motorola.ccc.ota | grep versionName
12:55:27.256 - adb shell rm -rf /sdcard/Download/* /sdcard/Backucup /sdcard/UCDownloads /data/local/tmp/tcpdump.cap /data/local/tmp/wpt_video.mp4
12:55:27.343 - adb shell su -c rm -rf /data/media/0/Download/* /data/media/0/Backucup /data/media/0/UCDownloads
12:55:27.597 - Android 7.0 (7.00)
12:55:27.770 - {'temp': 27.6, 'level': 100}
12:55:27.837 - adb shell su -c setprop sys.usb.config adb
12:55:27.887 - adb wait-for-device

Only after we disconnect/reconnect the device or restart adb USB mode via adb usb, SimpleRT continues:

Kernel driver is not active!
Device supports AOA 2.0!
Sending identification to the device
 sending manufacturer: Konstantin Menyaev
 sending model: SimpleRT
 sending description: Simple Reverse Tethering
 sending version: 1.0
 sending url: https://github.com/vvviperrr/SimpleRT
 sending serial number: 10.1.1.2,8.8.8.8
 sending command: start accessory
Accessory was inited successfully!
Found accessory 18d1:2d01
accessory connected!
pmeenan commented 7 years ago

:-/

FWIW, I run the SimpleRT tunnel in a separate process so the agent doesn't have to manage it. I have a tunnel.sh that is started in parallel with the agent:

#!/bin/bash
while :
do
  cd /home/pmeenan/wptagent/simple-rt/arm
  sudo ./simple-rt -i eth0 -n 192.168.0.1
  sleep 1
done

Longer term after I get tethering working on iOS (hopefully) I may replace SimpleRT with cleaner VPN and "adb reverse" which will hopefully help avoid some issues I have from time to time where the SimpleRT host Pi's go unresponsive.

sburnicki commented 7 years ago

Okay, thanks. We'll try some stuff and report any quirks/workarounds to avoid the issue :)

fsobanski commented 7 years ago

This commit should solve the second issue that sburnicki described. With that commit, reverse tethering will be configured for all devices that are connected when SimpleRT starts up. So there is no longer any need to diconnect/reconnect the device.

I based my fork on Eugenes fork of SimpleRT because it looks like the original author of SimpleRT vvviperrr hasn't been active on Github for the last few months and didn't accept the last pull request. So the newest commits are now on Eugenes fork.

fsobanski commented 7 years ago

I added a comment here to talk about the downside of my commit. (Additional unwanted terminal output)

eugene-sevostianov-sc commented 7 years ago

@fsobanski thank you for contributing. @sburnicki try my fork. Probably I solved all issues regarding connection without wifi and adjust app to 7+ android os version.

pmeenan commented 7 years ago

@eugene-sevostianov-sc @fsobanski Any chance either of you have pre-built APK's of the latest? The readme links still point to vvviperrr's. If not I'll see about installing the SDK's to get a build done.

pmeenan commented 7 years ago

I may also mod the server-side code if it doesn't handle the case yet but currently it keeps incrementing the IP address assigned even when assigning to the same device. It would be nice to have it re-assign the same IP to the same serial number if possible.

fsobanski commented 7 years ago

@pmeenan This app-debug.apk.tar.gz is an APK build from the head of my fork. I built it by following vvviperrr's readme instructions.

If you are considering to use the server-side code of my fork, please also look at my comment to this pull request