seedvault-app / seedvault

A backup application for the Android Open Source Project.
1.26k stars 74 forks source link

WebDAV error: DavException: Received redirect from HTTPS to HTTP #673

Closed thelazyoxymoron closed 3 months ago

thelazyoxymoron commented 4 months ago

Backup fails with the following error:

06-02 11:42:40.630 30094 30665 D BackupCoordinator: Resetting backup metadata...
06-02 11:42:40.631 30094 30665 I BackupCoordinator: Initialize Device!
06-02 11:42:40.645 30094 30665 E BackupCoordinator: Error initializing device
06-02 11:42:40.645 30094 30665 E BackupCoordinator: java.io.IOException: at.bitfire.dav4jvm.exception.DavException: Received redirect from HTTPS to HTTP
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at com.stevesoltys.seedvault.plugins.webdav.WebDavStoragePlugin.initializeDevice(WebDavStoragePlugin.kt:96)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at com.stevesoltys.seedvault.transport.backup.BackupCoordinator.initializeDevice(BackupCoordinator.kt:128)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at com.stevesoltys.seedvault.transport.ConfigurableBackupTransport$initializeDevice$1.invokeSuspend(ConfigurableBackupTransport.kt:128)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:1)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source:1)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at com.stevesoltys.seedvault.transport.ConfigurableBackupTransport.initializeDevice(ConfigurableBackupTransport.kt:127)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at android.app.backup.BackupTransport$TransportImpl.initializeDevice(BackupTransport.java:758)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at com.android.internal.backup.IBackupTransport$Stub.onTransact(IBackupTransport.java:649)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at android.os.Binder.execTransactInternal(Binder.java:1501)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at android.os.Binder.execTransact(Binder.java:1440)
06-02 11:42:40.645 30094 30665 E BackupCoordinator: Caused by: at.bitfire.dav4jvm.exception.DavException: Received redirect from HTTPS to HTTP
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at at.bitfire.dav4jvm.DavResource.followRedirects$build(DavResource.kt:616)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at at.bitfire.dav4jvm.DavResource.head(DavResource.kt:272)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     at com.stevesoltys.seedvault.plugins.webdav.WebDavStoragePlugin.initializeDevice(WebDavStoragePlugin.kt:88)
06-02 11:42:40.645 30094 30665 E BackupCoordinator:     ... 15 more
06-02 11:42:40.649  2053  4288 E BackupManagerService: Transport error in initializeDevice()
06-02 11:42:40.650 30094 30665 I BackupCoordinator: Request incremental backup time. Returned 0
06-02 11:42:40.651  2053  4288 W BackupManagerService: Init failed on com.stevesoltys.seedvault.transport.ConfigurableBackupTransport resched in 0
06-02 11:42:40.653  2053  2053 V BackupManagerService: Running a device init; 1 pending
06-02 11:42:40.653  2053  2053 V BackupManagerService: [UserID:0] initializeTransport(): [com.stevesoltys.seedvault.transport.ConfigurableBackupTransport]
06-02 11:42:40.653  2053  2053 V BackupManagerService: [UserID:0] Acquired wakelock:*backup*-0-4288
06-02 11:42:40.653  2053  4288 V BackupManagerService: [UserID:0] Released wakelock:*backup*-0-4288
06-02 11:42:40.654  2053  4288 I BackupManagerService: Initializing (wiping) backup transport storage: com.stevesoltys.seedvault.transport.ConfigurableBackupTransport
06-02 11:42:40.655 30094 30094 I BackupStateManager: appBackupRunning: false, filesBackupRunning: false, workInfoState: CANCELLED
06-02 11:42:40.656 30094 30094 D ConfigurableBackupTransportService: Service destroyed.
06-02 11:42:40.661 30094 30094 D ConfigurableBackupTransportService: Service created.
06-02 11:42:40.663 30094 30094 D ConfigurableBackupTransportService: Transport bound.

This is a valid webdav endpoint, works well with Finder network mount on MacOS and other places.

grote commented 3 months ago

We should probably surface this error to the user.

Did you see DavException: Received redirect from HTTPS to HTTP? Are you sure you want to use WebDAV over HTTP?

thelazyoxymoron commented 3 months ago

I'm not sure why is that error present in the first place though. I'm using the following setup:

Using docker-nginx-webdav-nononsense behind a reverse-proxy, so there should not be a redirection involved. I don't get this error with other clients.

grote commented 3 months ago

Can you privately provide a test account or install another instance of that container for testing?

thelazyoxymoron commented 3 months ago

Sure. How do I send the account details?

grote commented 3 months ago

Documenting the issues I've run into when testing with curl:

curl --user "user:pass" --head 'https://seedvault-backup-test.example.com/.NonExistentFolder'

If you run this in a terminal, you get the redirect to http. So that's something that sounds like a bug in that container? What I would expect here is to get a 404 response, since the folder doesn't exist yet.

curl -H 'Transfer-Encoding: chunked' -H 'Content-Type: image/png' --compressed -v --user "user:pass" -T test.png 'http://seedvault-backup-test.example.com/test.png' -v

Trying to upload a file (test.png) with curl also gives me 301 redirect and then doesn't upload.

So either something is wrong with @thelazyoxymoron's reverse proxy or these are strange bugs in the docker-nginx-webdav-nononsense container that we should report to upstream.