"autoexpire" does not seem to help solve the connection loss problem of kcptun
When the kcptun is disabled, everything is OK. Different from issue #801, connections will lose only if the device is put into sleep for a while. The client parameter is -key XXX -autoexpire 60. Logs on server are as follows:
[ERR] yamux: keepalive failed: i/o deadline reached
[ERR] yamux: Failed to read header: broken pipe
keepalive timeout
Simply push the Reset button in the app will solve the problem. Meanwhile, it works fine on windows client. So I believe there is nothing to do with the server.
Here is a table to better describes the issue:
| Setup | When the device is inuse | After wakeup from sleep | On Windows |
|---|---|---|---|
| shadowsock | OK | OK | OK |
| shadowsock + kcptun | OK | lose connection | OK |
Device info.: Samsung Galaxy Note 3, Android 5.0 root. Shadowsocks works in VPN mode.
It's expected that yamux would report timeout. When the connection loss happen, could you visit any sites on your device?
Also, please try smaller numbers of autoexpire, e.g 5.
I have bypass LAN & China enabled. When connection loses, I can still visit websites located in China, but I cannot open foreign websites.
I will try smaller number to see what happens, but I am concerned that it may cause battery drain.
It won't cause any battery drain. Actually, it may help to solve some battery drain related issues.
If you still see conntion loss after setting that number smaller than 5, then it's nothing to do with kcptun. Double check that the kcptun process isn't killed by any background service killer. This process is likely being killed by some agressive process managers, as it sends keep-alive packets frequently.
I've been testing this feature for 1 hr and no connection loss observed so far. :-)
Update: It turns out that I forgot to turn on kcp last time. Just experienced connection loss and it didn't reconnect in 60s.
When the connection lost, what's the CPU% of kcptun? Is it 100%? Or a large number like ~20%?
As I've enabled log for kcptun, could you try again and capture your log when connection lost?
adb logcat -s kcptun
OK. Reopen?
Forgot to do a manual reset. So no log dump.
However here's an interesting find: kcptun process is killed. Trying to run again...
I think this issue may be caused by a stupid bug that the stdout/stderr buffer becomes full for kcptun...
After redirect the log to logcat, I cannot detect connection loss any more. 😅
Hmm if that turns out to be the case, maybe we should just let kcptun flood logcat?
Already fixed here: https://github.com/shadowsocks/kcptun/commit/c4054b07a6b493f48d4e9c35c6c1a4a047462325
Ok. Just then my connection is super unstable (frequent mobile data switching). I wonder if that's causing kcptun not running. I'll test it again later.
I just pulled the latest commit (updated submodules, did a reset) and I'm not seeing anything on my logcat except ShadowsocksVpnService and GuardedProcess. Is this normal?
Could you see stream open/close with tag kcptun?
No. :confused:
Oh, did a clean and build again and it worked. Never mind...
Ok I experienced a connection loss twice just now and it reconnected after a while. From logcat I noticed that the session actually auto expire after 2 ~ 3 mins instead of the default 60 seconds. (network active during this time) Is this normal?
60s is the minimum time to expire a yamux session. So, it could be 2 or 3 mins, which depends on if there are new tcp connections created from shadowsocks.
Could you try a smaller number of autoexpire? For example, 10 seconds?