Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shadowsocks hangs with stopping #1122

Closed
3 of 18 tasks
KarlM256 opened this issue Feb 12, 2017 · 42 comments
Closed
3 of 18 tasks

shadowsocks hangs with stopping #1122

KarlM256 opened this issue Feb 12, 2017 · 42 comments

Comments

@KarlM256
Copy link

  • Android version: 6.0.1
  • Device: Motorola G4 Plus 64 GB
  • Shadowsocks version: 4.0.2 (4.0.1 also)
  • Last version that did not exhibit the issue (if applicable): 3.3.1

Configuration

Put an x inside the [ ] that applies.

  • IPv4 server address
  • IPv6 server address
  • Client IPv4 availability
  • Client IPv6 availability
  • Local port: 1080
  • Encrypt method: AES-128-CTR
  • One-time authentication
  • Route
    • All
    • [z] Bypass LAN
    • Bypass China
    • Bypass LAN & China
    • GFW List
    • China List
    • Custom rules
  • IPv6 route
  • Per-App Proxy
    • Bypass mode
  • UDP Forwarding
  • Plugin configuration (if applicable):
  • Auto Connect
  • TCP Fast Open
  • NAT mode

What did you do?

Start it. Then Stop it from the green paper airplane icon.

What did you expect to see?

I expected it to stop and be ready to restart.

What did you see instead?

It hung with the orange ring going around the green paper airplane. Text saying shutting down.
VPN icon still in the top android status bar.
I had to force stop the app.

@KarlM256
Copy link
Author

Changing the encryption to AES-128-GCM made no difference.
Attaching a screenshot

@KarlM256
Copy link
Author

screenshot_20170212-140504

@KarlM256
Copy link
Author

Can anyone else reproduce this?

@madeye
Copy link
Contributor

madeye commented Feb 13, 2017

Try uninstall and reinstall the app.

@KarlM256
Copy link
Author

Hi...

Tried uninstall and reinstall the app. No change..same problem.

Shadowsocks-Android 4.0.3
Shadowsocks-libev 3.0.2, although that does not seem to matter.

Tried a Nexus 6 running Android 7.0 and it worked fine.

I'll try it on another phone tonight.

Any other thoughts?

Thanks,

...Karl

@Mygod
Copy link
Contributor

Mygod commented Feb 13, 2017 via email

@KarlM256
Copy link
Author

I tried it on an LG G Flex 2 running android 5.1.1 and it works fine. (Frustrating)

@hanson-l
Copy link

hanson-l commented Feb 16, 2017

I also meet this problem when using kcptun on Samsung S6 running android 6.0.1.

@KarlM256
Copy link
Author

Do you mean that you were using shadowsocks-android with the kcptun plugin? If so, do you have the same problem without using the plugin? Can you disable the kcptun plugin on your android device and try it again?

@hanson-l
Copy link

Oh, the 4.0.2 ver. runs normally.

@V-E-O
Copy link
Contributor

V-E-O commented Feb 16, 2017

Came across same issue this morning with 4.0.3 and obfs plugin enabled. Solve it by clearing the SS activity.

@lingbaoboy
Copy link

貌似开启obfs会出现

@Mygod Mygod closed this as completed Feb 20, 2017
@Mygod
Copy link
Contributor

Mygod commented Feb 28, 2017 via email

@Mygod
Copy link
Contributor

Mygod commented Feb 28, 2017

Hmm... For now I'm suspecting 8d1f2da is causing this issue.

@Mygod Mygod reopened this Feb 28, 2017
@Mygod
Copy link
Contributor

Mygod commented Feb 28, 2017

@madeye What do you think? This problem looks like a third-party bug where SIGTERM is ignored for some reason. We could add a timeout and do SIGKILL instead but that would raise another problem for terminating plugin processes.

Another workaround is to maybe somehow kill :bg process group when doing a reset. And when users do a reset they can be sure that everything is terminated.

@madeye
Copy link
Contributor

madeye commented Feb 28, 2017

I think a delay of process.destroy() would do the trick. To ensure the process killed properly, we may first send SIGTERM, wait for 1 second then send SIGKILL.

I think all the latest plugins support detecting the detach or a parent process. So this change would not bring any side effect.

@Mygod
Copy link
Contributor

Mygod commented Feb 28, 2017

1 second for each process would add up to 4 seconds for service to shut down if it turns out it's their Android system that has bugged out. If we're really going to take this approach, how about half a sec? Or use a process pool to manage these processes which would involve even more work.

Another thing is SIGTERM is always used since Android 7.0 so I assume it's a bug of their ROM. I still think the better solution is not to fix this device-specific issue to kill the process group when user presses Reset and buggy ROMs can always reset if something goes wrong in :bg.

@madeye
Copy link
Contributor

madeye commented Feb 28, 2017

@Mygod OK, to keep things clean, let's just kill :bg in reset action for now.

Also, let's see if there are more similar issues after the first stable release pushed to more users.

@KarlM256
Copy link
Author

I have a new logcat with kcptun. However, uploading the txt file fails with the message "Something went really wrong, and we can’t process that file. Try again.".

@KarlM256
Copy link
Author

log.txt

The upload worked from my phone.

@madeye
Copy link
Contributor

madeye commented Mar 1, 2017

@Mygod According to some feedbacks in Google Play, this issue seems to happen on many Moto devices.

I implemented a waitpid with the WNOHANG flag to have a timeout here via a61b03c. After some quick tests, it seems to work well.

@madeye
Copy link
Contributor

madeye commented Mar 1, 2017

@KarlM256
Copy link
Author

KarlM256 commented Mar 1, 2017

Hi...

I just tried the 4.1.0 apk. When I use shadowsocks without any plugins, the change works fine. I can see the delay for the timeout, but it disconnects fine. When I run shadowsocks with the kcptun plugin, it still hangs. The symptoms are slightly different. If I force stop shadowsocks, that disconnects as before. However, previously I could also disconnect by first touching the paper airplane icon, then I could connect to private tunnel with the openvpn app. Shadowsocks would give a dialog box with "Unfortunately shadowsocks has stopped working" I would then click ok and disconnect openvpn. After that, shadowsocks was disconnected again as I desired.

Now only the force stop method works (when kcptun is used). Connecting with openvpn does not cause the dialog box and it does not cause shadowsocks to disconnect.

If additional logs would be useful, please describe what you would like to see.

@KarlM256
Copy link
Author

KarlM256 commented Mar 1, 2017

Hi...

I have a question. The hanging problem started only with recent shadowsocks-android versions. How did you terminate the background task differently in the past vs how you terminate it now?

Thanks,

...Karl

@madeye
Copy link
Contributor

madeye commented Mar 1, 2017

@KarlM256
Copy link
Author

KarlM256 commented Mar 1, 2017

With both of your recent apks, shadowsocks starts and stops with and without kcptun. Nice job working around my bad Moto factory ROM.

Is the obfuscation plugin and server in working order? Should I set up to try them yet?

@madeye
Copy link
Contributor

madeye commented Mar 1, 2017

You can also try simple-obfs. It should work now.

@Mygod
Copy link
Contributor

Mygod commented Mar 1, 2017

I did some research and unfortunately process group is introduced back in Lollipop. And it seems this bug can be worked around by using Reset already.

Mygod added a commit that referenced this issue Mar 1, 2017
@Mygod
Copy link
Contributor

Mygod commented Mar 1, 2017

Try 8677308? @madeye

@madeye
Copy link
Contributor

madeye commented Mar 2, 2017

@Mygod It crashed on Android 4.4.

E/dalvikvm( 2345): Fatal error: ProcessManager$ProcessImpl.exitValue not found

Maybe we'd better not use private API here.

@madeye
Copy link
Contributor

madeye commented Mar 2, 2017

Hmm, it turns out to be a typo. Fixed via d5d6740.

@madeye
Copy link
Contributor

madeye commented Mar 2, 2017

@KarlM256
Copy link
Author

KarlM256 commented Mar 2, 2017

The latest version looks good. I just installed and tested with shadowsocks alone, with KCP and with OBFS. All three worked. Just to be clear...The previous apk and this one were both named 4.1.0. I did an install and it succeeded, but I can't independently verify the version of my apk.

@madeye
Copy link
Contributor

madeye commented Mar 2, 2017

@KarlM256 Thanks! The latest one should override the previous one. I think they both works for you now.

@KarlM256
Copy link
Author

KarlM256 commented Mar 2, 2017

With the new plugin approach, clearly the UDP forwarding option can not work with a plugin because the port number for the plain shadowsocks server is unknown.

However I have noticed that SIP connections fail to work without UDP forwarding. I can only try this without using a plugin. That is, unless I use the android client without a plugin and enable UDP forwarding, SIP connections fail. If I enable UPD forwarding and do not use a plugin, SIP connections work.

@KarlM256
Copy link
Author

KarlM256 commented Mar 2, 2017

From issue #1022, I want to clarify, does shadowsocks do UDP over TCP when UDP forwarding is not selected?

@madeye
Copy link
Contributor

madeye commented Mar 2, 2017

With the new plugin approach, clearly the UDP forwarding option can not work with a plugin because the port number for the plain shadowsocks server is unknown.

The UDP port is still the same. The only exception is KCPTUN, which requires a trick here: #1090 (comment)

However I have noticed that SIP connections fail to work without UDP forwarding. I can only try this without using a plugin. That is, unless I use the android client without a plugin and enable UDP forwarding, SIP connections fail. If I enable UPD forwarding and do not use a plugin, SIP connections work.

SIP is a UDP protocol, So, you need to enable UDP forwarding.

From issue #1022, I want to clarify, does shadowsocks do UDP over TCP when UDP forwarding is not selected?

Nope, disabling UDP means dropping all UDP packets locally.

@KarlM256
Copy link
Author

KarlM256 commented Mar 2, 2017

So if UDP forwarding is selected, are the UDP packets sent through the plugin? Are UDP packets obfuscated? What does KCP do with UDP packets?

@madeye
Copy link
Contributor

madeye commented Mar 2, 2017

So if UDP forwarding is selected, are the UDP packets sent through the plugin? Are UDP packets obfuscated? What does KCP do with UDP packets?

All UDP traffic should bypass the SIP003 plugin.

@KarlM256
Copy link
Author

KarlM256 commented Mar 2, 2017

Wouldn't it make sense to obfuscate UDP traffic as well as TCP?

@madeye
Copy link
Contributor

madeye commented Mar 2, 2017

Wouldn't it make sense to obfuscate UDP traffic as well as TCP?

No plan for this.

@KarlM256
Copy link
Author

KarlM256 commented Mar 2, 2017

When using kcptun with incorrect options shadowsocks android hangs on shutdown. I had the u option in the plugin options in android. Testing the connection timed out and shutting down the connection hung, requiring a force stop.

@KarlM256 KarlM256 closed this as completed Mar 7, 2017
bannedbook pushed a commit to bannedbook/SpeedUp.VPN that referenced this issue Dec 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants