shadowsocks / shadowsocks-android

A shadowsocks client for Android
Other
35.18k stars 11.58k forks source link

Media upload problem in Telegram since upgraded to shadowsocks-rust 1.9 #2681

Closed arbabseyfola closed 3 years ago

arbabseyfola commented 3 years ago

Please read contributing guidelines. Thanks.

There is a problem in Telegram media uploading since shadowsocks rust was updated to version 1.9. Same problem exist in telegram desktop with shadowsocks rust 1.9 client.

Expected behavior Start upload media after sending.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Configuration Put an x inside the [ ] that applies.

Additional context Add any other context about the problem here.

madeye commented 3 years ago

@zonyitoo Can you take a look?

I can reproduce this locally.

madeye commented 3 years ago

@arbabseyfola Can you confirm that the plugin is enabled in your profile?

I cannot reproduce this issue with any SIP003 plugin enabled.

madeye commented 3 years ago

Interesting, it seems not able to be reproduced every time.

@arbabseyfola When this issue happening, can you kill telegram then try again? It's not clear how telegram implements its uploading mechanism, but it seems working from my side.

arbabseyfola commented 3 years ago

@arbabseyfola Can you confirm that the plugin is enabled in your profile?

I cannot reproduce this issue with any SIP003 plugin enabled.

Yes. V2ray plugin is used.

arbabseyfola commented 3 years ago

Interesting, it seems not able to be reproduced every time.

@arbabseyfola When this issue happening, can you kill telegram then try again? It's not clear how telegram implements its uploading mechanism, but it seems working from my side.

This happens most of times for me. Force stop android app did not help. No such problem in 5.1.7 and before.

zonyitoo commented 3 years ago

It is working on my Laptop with Telegram Desktop 2.5.9, macOS.

Running sslocal v1.9.0 in HTTP mode. I am trying with the SOCKS5 mode.

EDIT: SOCKS5 mode is also working.

image

dev4u commented 3 years ago

It is working on my Laptop with Telegram Desktop 2.5.9, macOS.

Running sslocal v1.9.0 in HTTP mode. I am trying with the SOCKS5 mode.

EDIT: SOCKS5 mode is also working.

PO主用的是手机版telegram,你好像没有安卓机,难为你了。

zonyitoo commented 3 years ago

Same problem exist in telegram desktop with shadowsocks rust 1.9 client.

Author confirmed that the Desktop version can also reproduce this issue.

dev4u commented 3 years ago

我这边重现不了。 mi9 pro telegram v7.5.0 2243

P.S.试试清除发送的缓存再试试。进入的方法:长按下方的版本。

IMG_20210224_111814.jpg

arbabseyfola commented 3 years ago

Same problem exist in telegram desktop with shadowsocks rust 1.9 client.

Author confirmed that the Desktop version can also reproduce this issue.

Now I Can't reproduce it on the desktop again! But android version has problem.

madeye commented 3 years ago

@arbabseyfola can you try enabling airplane mode then disabling it, when you see the issue happens.

arbabseyfola commented 3 years ago

@arbabseyfola can you try enabling airplane mode then disabling it, when you see the issue happens.

It was not effective. But often a few times of stops and starts within the program solves the problem.

madeye commented 3 years ago

It's still not clear to me why we see the stuck here. It should be related to how telegram do the uploading.

But one workaround is setting SOCKS5 proxy in telegram to 127.0.0.1:1080. It should solve your issue for now.

arbabseyfola commented 3 years ago

It's still not clear to me why we see the stuck here. It should be related to how telegram do the uploading.

But one workaround is setting SOCKS5 proxy in telegram to 127.0.0.1:1080. It should solve your issue for now.

Often I use proxy only mode with socks In telegram and same problem exist. Shadoesocks 5.1.7 has not such problem.

zonyitoo commented 3 years ago

What exactly was the problem like? The program hangs or reports errors?

madeye commented 3 years ago

If setting SOCKS5 proxy didn't work for you, I guess you should be able to reproduce this on desktop as well.

@zonyitoo The uploading progress is freezing. From my local tests, switching airplane mode can force Telegram retry the uploading and get this issue temporally solved.

zonyitoo commented 3 years ago

It is working on my Laptop with Telegram Desktop 2.5.9, macOS. Running sslocal v1.9.0 in HTTP mode. I am trying with the SOCKS5 mode. EDIT: SOCKS5 mode is also working.

PO主用的是手机版telegram,你好像没有安卓机,难为你了。

I managed to install an Android x86 emulator, and then sslocal reports: ERROR accept failed with error: Function not implemented (os error 38)... Da**

Which means that this version of Android doesn't have accept4

dev4u commented 3 years ago

I managed to install an Android x86 simulator, and then sslocal reports: ERROR accept failed with error: Function not implemented (os error 38)... Da**

Which means that this version of Android doesn't have accept4

这可能是个找问题的思路。 我的建议是,因为po主正常能用的版本,跟当前异常的版本相差有点大:ss升级了多进程模式、rust升级了tokio……所以能不能通过升级中间的版本来确认大概是什么时候的commit引入的问题。至少不用靠猜来确认。

zonyitoo commented 3 years ago

Ok, I managed to run shadowsocks-android on an Android emulator.

image

It is working well without plugins.

The .apk I downloaded from Releases doesn't ship with any plugins, so I cannot test with v2ray-plugin. How to install v2ray-plugin manually?

madeye commented 3 years ago

You can download the APK here: https://github.com/shadowsocks/v2ray-plugin-android/releases/tag/v1.3.3

zonyitoo commented 3 years ago

Working perfectly correctly with v2ray-plugin:

image

Couldn't reproduce after multiple trials.

madeye commented 3 years ago

After updating to the latest telegram (Feb 25), I cannot reproduce this issue anymore...

zonyitoo commented 3 years ago

Hmm, so Telegram is the one to be blame?

arbabseyfola commented 3 years ago

The problem still exists!

Screenshot_2021-02-25-14-45-29-995_org telegram messenger IMG_20210225_144755 Screenshot_2021-02-25-14-45-52-002_com github shadowsocks Screenshot_2021-02-25-14-46-35-894_com miui securitycenter

Server side : Shadowsocks-libev v3.3.5 + v2ray plugin v1.3.1

dev4u commented 3 years ago

我遇过类似的问题,不过不是在telegram,而是在youtube app。 不用插件看看会不会缓解这种现象。

arbabseyfola commented 3 years ago

我遇过类似的问题,不过不是在telegram,而是在youtube app。 不用插件看看会不会缓解这种现象。

In my country, the traffic of servers without plugins is detected and blocked very quickly.

dev4u commented 3 years ago

方便展示一下你的插件在C/S上的运行参数吗? 如果可能,请试试如下操作: 调低tcp的超时时间,例如120s 服务端的mode设定为tcp_only。

zonyitoo commented 3 years ago

I was testing it with Telegram for Android v7.0.5 (2245) x86_64.

Some hints for moving this issue forward:

  1. Compatibility issue between sslocal and ssserver Try to replace ssserver from libev to the rust version and see if the problem still exists.
  2. Server issue Your connection between servers are unstable, which leads to packet drops occationally. If v2ray-plugin failed to connect the remote server, then sslocal normally won't report "connection failed" but blocks on read() for a very long time, because v2ray-plugin won't RST the connection actively.

Since I cannot reproduce this issue locally, I highly suspect it was the Server's issue.

madeye commented 3 years ago

One possible issue is related to the long TCP connection. Maybe telegram tries to reuse some TCP connections, but they're already closed silently by shadowsocks due to timeout or something else.

@arbabseyfola Try shadowsocks-rust as your server, and make sure the server timeout is large enough, say > 3600 seconds.

dev4u commented 3 years ago
  1. Server issue Your connection between servers are unstable, which leads to packet drops occationally. If v2ray-plugin failed to connect the remote server, then sslocal normally won't report "connection failed" but blocks on read() for a very long time, because v2ray-plugin won't RST the connection actively.

我认可这个猜测。建议在不清楚什么状况下,不要设置太大的超时时间。 另外有个现象可以观察一下,客户端发生等待、阻塞前,服务端是不是有发生数据重放?

arbabseyfola commented 3 years ago

One possible issue is related to the long TCP connection. Maybe telegram tries to reuse some TCP connections, but they're already closed silently by shadowsocks due to timeout or something else.

@arbabseyfola Try shadowsocks-rust as your server, and make sure the server timeout is large enough, say > 3600 seconds.

I apologize for the delay. I tested with shadowsocks-rust V1.9.1 server and it seems that this problem no longer exists. The shadowsocks-rust client doesn't seem to be adhering to the shadowsocks protocol properly.

zonyitoo commented 3 years ago

The shadowsocks-rust client doesn't seem to be adhering to the shadowsocks protocol properly.

I doubt that. It seems to be a compatible issue.

There should be no problem in the protocol level, or this problem must be presented in all of our previous tests.

I highly suspected that it is related to the timeout configurations.

arbabseyfola commented 3 years ago

The shadowsocks-rust client doesn't seem to be adhering to the shadowsocks protocol properly.

I doubt that. It seems to be a compatible issue.

There should be no problem in the protocol level, or this problem must be presented in all of our previous tests.

I highly suspected that it is related to the timeout configurations.

How much timeout should I set?

zonyitoo commented 3 years ago

Just delete it.

arbabseyfola commented 3 years ago

Just delete it.

Nothing changed!

zonyitoo commented 3 years ago

Any idea? @madeye

madeye commented 3 years ago

Yes, I think it's an issue related to timeout settings on the server.

arbabseyfola commented 3 years ago

Yes, I think it's an issue related to timeout settings on the server.

There is no problem with the same settings and ss-rust server.

madeye commented 3 years ago

Set the timeout to 3600 for shadowsocks-libev server and try again.

The timeout logic would be sightly different between implementations.

arbabseyfola commented 3 years ago

Set the timeout to 3600 for shadowsocks-libev server and try again.

The timeout logic would be sightly different between implementations.

Nothing changed. The problem still exists

madeye commented 3 years ago

Post your server's config file here.

arbabseyfola commented 3 years ago

Post your server's config file here.

My Config

ENV SERVER_ADDR 0.0.0.0 ENV SERVER_PORT 443 ENV TIMEOUT 3600 ENV METHOD chacha20-ietf-poly1305 ENV PASSWORD xxxxxxx ENV ARGS --plugin v2ray-plugin --plugin-opts server;host=** -u

CMD exec ss-server \ -s $SERVER_ADDR \ -p $SERVER_PORT \ -k $PASSWORD \ -m $METHOD \ -t $TIMEOUT \ -d $DNS_ADDRS \ --reuse-port \ --no-delay \ $ARGS

madeye commented 3 years ago

Try remove the following items

--reuse-port --no-delay

If it still doesn't work, please use shadowsocks-rust for now.

arbabseyfola commented 3 years ago

Try remove the following items

--reuse-port --no-delay

If it still doesn't work, please use shadowsocks-rust for now.

Not working :(

Mygod commented 3 years ago

So... what's the state on this issue?

zonyitoo commented 3 years ago

Couldn't reproduce and don't know why.

Mygod commented 3 years ago

Closing due to inactivity.

FinecoFinit commented 3 years ago

Hey, the problem is still exist. Pls, reopen

zonyitoo commented 3 years ago

Could you reproduce?

thegreathir commented 3 years ago

Still problem here... I setup shadowsocks-libev (v3.3.5) and v2ray-plugin (v1.3.1) on server and shadowsocks android (v5.2.5) and v2ray(v1.3.2) on my android phone. Both client apps are installed from google play. I can not send any media in telegram application.

After switching server side program to shadowsocks-rust (v1.11.2) everything fixed and I can upload anything without problem. I just want to notify you that problem is still there and if you think it is a shadowsocks-libev problem tell me to issue it on their repo. But I think the problem is related to android client because with my libev sever, Shadowrocket (iOS client) worked fine.

NOTE: I played with "timeout" in configuration and nothing changed. (I set to 60, 100, 200, 3600, 7200, not set)