nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.15k stars 1.75k forks source link

Connection issues with android 11 and proxies #9630

Open idlefella opened 2 years ago

idlefella commented 2 years ago

Hi

I have the problem that nextcloud always stopped working after a while and I addressed the problem a bit further but wasn't able to resolve it.

I think the main problem is that my mobile connection has a proxy set by the provider. When I go to Android Settings -> Wi-Fi & Network -> SIM & Network -> SIM 1 (Provider) -> Access point names -> XXX Service and look at the details, I see that I need to use a proxy, in my case it's 192.168.210.1:8080

Somehow this proxy setting is never dropped even when I change the connection. This causes multiple issues, some of them are SocketTimeoutExceptions and even UnknownHostExceptions. Here are the steps to reproduce:

Steps to reproduce

  1. Install Nextcloud app (tested with v3.18.1) (I realized that it's important to reinstall it, because the caching seems to be pretty aggressive and I can't make the app forget about the proxy if the app was used before)
  2. Open the app with a mobile connection set with a proxy.
  3. Enter the demo server address: https://demo1.nextcloud.com
  4. The test succeeds and you get redirected to the next page, where you can Log In by granting access. Don't continue here, but press the back button.
  5. Switch to another connection without a proxy, e.g. Wifi and wait untill the phone uses the wifi connection.
  6. Press again Login and try the previously used url address https://demo1.nextcloud.com
  7. The connections runs into a timeout. The app shows (after ~50s): The server too too long to respond.

adb logcat shows the following:

12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation: Connection check at https://demo1.nextcloud.com: Connect timeout exception
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation: org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 50000 ms
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:155)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:125)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:200)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:171)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.resources.status.GetStatusRemoteOperation.tryConnection(GetStatusRemoteOperation.java:89)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.resources.status.GetStatusRemoteOperation.run(GetStatusRemoteOperation.java:200)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:187)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.operations.GetServerInfoOperation.run(GetServerInfoOperation.java:80)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:187)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.services.OperationsService$ServiceHandler.nextOperation(OperationsService.java:440)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.services.OperationsService$ServiceHandler.handleMessage(OperationsService.java:405)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at android.os.Handler.dispatchMessage(Handler.java:106)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at android.os.Looper.loop(Looper.java:233)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at android.os.HandlerThread.run(HandlerThread.java:67)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation: Caused by: java.net.SocketTimeoutException: failed to connect to /192.168.210.1 (port 8080) from /192.168.0.24 (port 41099) after 50000ms: isConnected failed: ETIMEDOUT (Connection timed out)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at libcore.io.IoBridge.isConnected(IoBridge.java:283)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at libcore.io.IoBridge.connectErrno(IoBridge.java:192)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at libcore.io.IoBridge.connect(IoBridge.java:134)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at java.net.Socket.connect(Socket.java:621)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at java.lang.reflect.Method.invoke(Native Method)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  ... 19 more
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation: Caused by: android.system.ErrnoException: isConnected failed: ETIMEDOUT (Connection timed out)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  at libcore.io.IoBridge.isConnected(IoBridge.java:274)
12-28 21:40:00.166  5195 15486 E GetStatusRemoteOperation:  ... 29 more

As you can see, it still tries to connect to the proxy (failed to connect to /192.168.210.1 (port 8080))

Even switching back to the previous connection with the mobile provider doesn't resolve the issue. I still get a SocketTimeoutException (although the proxy is still used):

12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation: Connection check at https://demo1.nextcloud.com: Connect timeout exception
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation: org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 50000 ms
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:155)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:125)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:200)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:171)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.resources.status.GetStatusRemoteOperation.tryConnection(GetStatusRemoteOperation.java:89)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.resources.status.GetStatusRemoteOperation.run(GetStatusRemoteOperation.java:200)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:187)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.operations.GetServerInfoOperation.run(GetServerInfoOperation.java:80)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:187)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.services.OperationsService$ServiceHandler.nextOperation(OperationsService.java:440)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at com.owncloud.android.services.OperationsService$ServiceHandler.handleMessage(OperationsService.java:405)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at android.os.Handler.dispatchMessage(Handler.java:106)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at android.os.Looper.loop(Looper.java:233)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at android.os.HandlerThread.run(HandlerThread.java:67)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation: Caused by: java.net.SocketTimeoutException: failed to connect to /192.168.210.1 (port 8080) from /10.14.20.72 (port 47159) after 50000ms: isConnected failed: ETIMEDOUT (Connection timed out)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at libcore.io.IoBridge.isConnected(IoBridge.java:283)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at libcore.io.IoBridge.connectErrno(IoBridge.java:192)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at libcore.io.IoBridge.connect(IoBridge.java:134)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at java.net.Socket.connect(Socket.java:621)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at java.lang.reflect.Method.invoke(Native Method)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  ... 19 more
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation: Caused by: android.system.ErrnoException: isConnected failed: ETIMEDOUT (Connection timed out)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  at libcore.io.IoBridge.isConnected(IoBridge.java:274)
12-28 21:44:11.688  5195 15486 E GetStatusRemoteOperation:  ... 29 more

Closing and reopening the app doesn't resolve the issue. Also deleting the app cache doesn't help. Even deleting the "App Data" (Clear storage) doesn't make the app work again. I really need to deinstall and reinstall it.

I even managed that logcat reported a "UnknownHostException", but I'm currently not able to reproduce that.

Expected behaviour

Actual behaviour

Can you reproduce this problem on https://try.nextcloud.com?

Environment data

Android version: Android 11

Device model: Oneplus 6

Stock or customized system: Stock

Nextcloud app version: v3.18.1

Nextcloud server version: Server version is irrelevant, but I tested with the demo1.nextcloud.com

Reverse proxy:

Nextcloud log (data/nextcloud.log)

Insert your Nextcloud log here

NOTE: Be super sure to remove sensitive data like passwords, note that everybody can look here! You can use the Issue Template application to prefill some of the required information: https://apps.nextcloud.com/apps/issuetemplate

Wozzagonebush commented 2 years ago

Similar problems here. Samsung S10 and Tab 5 NC app both just sit there "trying to connect". I can connect just fine using Firefox browser on both. No problems with iPad app connectivity.

joshtrichards commented 11 months ago

Looks similar to #7138 (and #8625)