Genymobile / gnirehtet

Gnirehtet provides reverse tethering for Android
Apache License 2.0
6.24k stars 573 forks source link

Always disconnecting after few minutes #162

Open breekoy opened 5 years ago

breekoy commented 5 years ago

I always keep disconnecting after a few minutes of using.

The terminal returns this message: 2018-12-17 15:21:25.568 INFO TunnelServer: Client #0 disconnected

breekoy commented 5 years ago

here's my logcat by the way

logcat.txt

rom1v commented 5 years ago

Your device kills many applications (including gnirehtet) regularly.

12-17 15:07:04.083  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.084  1417 10306 E libprocessgroup: failed to kill 1 processes for processgroup 7905
12-17 15:07:04.105  1417  1555 I ActivityManager: Force stopping com.colors.simplevisitormode appid=1000 user=0: from pid 10237
12-17 15:07:04.106  1417  1555 I ActivityManager: Killing 10034:com.colors.simplevisitormode/1000 (adj 9): stop com.colors.simplevisitormode
12-17 15:07:04.107  1417  1555 D ActivityManager: cleanUpApplicationRecord -- 10034
12-17 15:07:04.114  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.125  1417 10307 E libprocessgroup: failed to kill 1 processes for processgroup 10034
12-17 15:07:04.151  1417  1443 I ActivityManager: Force stopping com.android.quicksearchbox appid=10103 user=0: from pid 10237
12-17 15:07:04.152  1417  1443 I ActivityManager: Killing 9934:com.android.quicksearchbox/u0a103 (adj 9): stop com.android.quicksearchbox
12-17 15:07:04.152  1417  1443 D ActivityManager: cleanUpApplicationRecord -- 9934
12-17 15:07:04.157  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.164  1417 10308 E libprocessgroup: failed to kill 1 processes for processgroup 9934
12-17 15:07:04.189  1417  1443 I ActivityManager: Force stopping com.coloros.notificationmanager appid=1000 user=0: from pid 10237
12-17 15:07:04.190  1417  1443 I ActivityManager: Killing 9908:com.coloros.notificationmanager/1000 (adj 11): stop com.coloros.notificationmanager
12-17 15:07:04.190  1417  1443 D ActivityManager: cleanUpApplicationRecord -- 9908
12-17 15:07:04.196  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.204  1417 10309 E libprocessgroup: failed to kill 1 processes for processgroup 9908
12-17 15:07:04.227  1417  2524 I ActivityManager: Force stopping com.google.android.partnersetup appid=10014 user=0: from pid 10237
12-17 15:07:04.228  1417  2524 I ActivityManager: Killing 9427:com.google.android.partnersetup/u0a14 (adj 11): stop com.google.android.partnersetup
12-17 15:07:04.229  1417  2524 D ActivityManager: cleanUpApplicationRecord -- 9427
12-17 15:07:04.235  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.261  1417  2591 I ActivityManager: Force stopping com.google.android.apps.photos appid=10141 user=0: from pid 10237
12-17 15:07:04.262  1417  2591 I ActivityManager: Killing 7957:com.google.android.apps.photos/u0a141 (adj 11): stop com.google.android.apps.photos
12-17 15:07:04.262  1417  2591 D ActivityManager: cleanUpApplicationRecord -- 7957
12-17 15:07:04.267  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.279  1417 10311 E libprocessgroup: failed to kill 1 processes for processgroup 7957
12-17 15:07:04.353  1417  2591 I ActivityManager: Force stopping com.nearme.sync appid=10091 user=0: from pid 10237
12-17 15:07:04.354  1417  2591 I ActivityManager: Killing 7939:com.nearme.sync/u0a91 (adj 8): stop com.nearme.sync
12-17 15:07:04.355  1417  2591 D ActivityManager: cleanUpApplicationRecord -- 7939
12-17 15:07:04.357  1417  2591 I ActivityManager:   Force stopping service ServiceRecord{e511c26 u0 com.nearme.sync/.services.AutoSyncService}
12-17 15:07:04.359  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.367  1417 10312 E libprocessgroup: failed to kill 1 processes for processgroup 7939
12-17 15:07:04.390  1417  2591 I ActivityManager: Force stopping com.coloros.simsettings appid=1000 user=0: from pid 10237
12-17 15:07:04.391  1417  2591 I ActivityManager: Killing 7924:com.coloros.simsettings/1000 (adj 1): stop com.coloros.simsettings
12-17 15:07:04.392  1417  2591 D ActivityManager: cleanUpApplicationRecord -- 7924
12-17 15:07:04.394  1417  2591 I ActivityManager:   Force stopping service ServiceRecord{99fb449 u0 com.coloros.simsettings/com.coloros.datamonitor.service.DataUsageService}
12-17 15:07:04.394  1417  2591 I ActivityManager:   Force stopping service ServiceRecord{c3eb023 u0 com.coloros.simsettings/.ColorAppServicesManagerClient}
12-17 15:07:04.397  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.406  1417 10313 E libprocessgroup: failed to kill 1 processes for processgroup 7924
12-17 15:07:04.427  1417  2524 I ActivityManager: Force stopping com.genymobile.gnirehtet appid=10193 user=0: from pid 10237
12-17 15:07:04.428  1417  2524 I ActivityManager: Killing 9266:com.genymobile.gnirehtet/u0a193 (adj 1): stop com.genymobile.gnirehtet
12-17 15:07:04.428  1417  2524 D ActivityManager: cleanUpApplicationRecord -- 9266
12-17 15:07:04.435  1417  2524 I ActivityManager:   Force stopping service ServiceRecord{c7c774a u0 com.genymobile.gnirehtet/.GnirehtetService}
12-17 15:07:04.441  1417 10314 E libprocessgroup: failed to kill 1 processes for processgroup 9266
12-17 15:07:04.448  1417  1417 D JobSchedulerService: Receieved: android.intent.action.PACKAGE_RESTARTED
12-17 15:07:04.479  1417  2592 I ActivityManager: Start proc 10315:com.coloros.notificationmanager/1000 for content provider com.coloros.notificationmanager/.PowerProvider
12-17 15:07:04.505  1417  1443 I ActivityManager: Force stopping com.coloros.phonenoareainquire appid=10108 user=0: from pid 10237
12-17 15:07:04.505  1417  1443 I ActivityManager: Killing 8174:com.coloros.phonenoareainquire/u0a108 (adj 15): stop com.coloros.phonenoareainquire
12-17 15:07:04.506  1417  1443 D ActivityManager: cleanUpApplicationRecord -- 8174

Which device is it? (is it Huawei?)

breekoy commented 5 years ago

No, it's Oppo. I already turned off battery optimization because I thought that's the culprit but still no luck.

rom1v commented 5 years ago

Does it still kill your apps with battery optimisation disabled?

breekoy commented 5 years ago

yes, but now instead of killing while still the device is in use, it only kills when the screen is turned off. I couldn't find any option to disable this behavior on my device, I guess I will have to deal with this. 😞

Y-T-G commented 5 years ago

I am having disconnection issue too. It happens after a certain amount of transfer. The adb stops working completely and I have to reconnect my phone. Logcat:

2018-12-18-22-05-03.txt

rom1v commented 5 years ago

The adb stops working completely

OK, so this is lower level (adb or usb). Please try with another cable.

Y-T-G commented 5 years ago

It is happening only with gnirehtet running. I can run adb logcat for a long time but it won't disconnect but it disconnects after a while if gnihrehtet is running.

rom1v commented 5 years ago

It is happening only with gnirehtet running.

USB/adb can "fail" when you transfer a lot of data. Does it happen if gnirehtet is running, but you don't transfer any data?

Y-T-G commented 5 years ago

Does it happen if gnirehtet is running, but you don't transfer any data?

No, it doesn't happen. It happens after approximately 25MB of transfer. It used to work fine before. I had an update to my ROM recently. Maybe it changed something in the way adb works.

shiranxbird commented 5 years ago

were you able to figure this out?

mythsman commented 3 years ago

I think I just find a 'stupid' solution to this .

The problem is that the Android system always tries to stop background services. So we can just lock the activity on start up like this:

https://user-images.githubusercontent.com/11818556/110473158-2f243680-8119-11eb-92de-39818113e566.mp4

rom1v commented 3 years ago

@mythsman Which device/ROM is it? Some devices were known to kill background services, causing problems (for example VLC audio player was killed while playing).

mythsman commented 3 years ago

@mythsman Which device/ROM is it? Some devices were known to kill background services, causing problems (for example VLC audio player was killed while playing).

I'm using xiaomi...

mythsman commented 3 years ago

@mythsman Which device/ROM is it? Some devices were known to kill background services, causing problems (for example VLC audio player was killed while playing).

By the way, I'm using gnirehtet in production with five linux server , each connected with 40 devices. I'm using relay-java and I find that the relay severs always throw OOM exception after running for some hours . I dump the heap and figure out I was because each 'Client' holds many connections (for about 400 ), and each 'TCPConnection' holds a streamBuffer of about 256KB . 256KB 400 40 ≈ 4G , which eats out my poor heap...

Therefore I add a limit of 200 conections in each Router::connections , and then it work properly.

So I think it would be great if we could configure the 'limit of connections for each router' at start up...

Amdadullah-Raihan commented 1 year ago

The connection gets disconnected automatically after a few minutes. How can I solve this?

robertwt7 commented 1 year ago

this is still happening for me. one of the thing that helps was to go to apps -> gnirehtet -> app battery usage -> select unrestricted

it helps to add a few more minutes. but other than that, using a stock cable from google pixel 7 pro with macbook pro port doesn't seem to last for a long time