obsidian-livesync icon indicating copy to clipboard operation
obsidian-livesync copied to clipboard

Not working on mobile

Open thany opened this issue 11 months ago • 43 comments

Abstract

It doesn't connect to couchdb on mobile only. Exactly the same settings as on desktop, but on desktop it works totally fine. Even when on the exact same wifi network, without VPN and such. In a browser (on mobile) I can also successfully open the couchdb url, which proves to me that the connection to the server is functioning correctly.

I'm on the latest Obsidian for Android 14, and the latest Livesync addon.

Expected behaviour

  • Synchronisation ends with the message Replication completed
  • Everything synchronised

Actually happened

  • Synchronisation has been cancelled with a generic "Failed to fetch" error.
  • No files synchronised

Reproducing procedure

  1. Replicate on mobile.

Note: If you do not catch the reproducing procedure, please let me know the frequency and signs.

Report materials

If the information is not available, do not hesitate to report it as it is. You can also of course omit it if you think this is indeed unnecessary. If it is necessary, I will ask you.

Report from the LiveSync & Obsidian debug info & Plug-in log

Can't really do that, because the problem only occurs on mobile, and I can't access github on mobile, atm. Please let me know what specifically you need and I'll try adding it somehow.

Network log

Can't access the devtools on mobile. Or at least I can't figure out how.

thany avatar Feb 27 '24 16:02 thany

I have a similar problem, except mine says it successfully replicates. However, changes never get pushed to the desktop. It was working fine between all devices, but stopped this week -- just checking, Obsidian pushed the 1.5.8 version to both desktop and mobile on February 22nd, so I think something changed which may be affecting sync. Completely redid the database, no fix. Redid all of the LiveSync settings one-device at a time, no change. DB reflects Desktop -> DB, but mobile seems to be having issues (renames, add blocks to notes, etc. don't reflect back).

edit Some more testing.

  • Completely blew out both devices (desktop and mobile) and database.
  • Setup on desktop and let it sync to (is master, has all of the documents) the new database, worked fine.
  • Setup on mobile and let it pull to a fresh (empty) folder, worked fine, initial fetch replicated successfully.
  • With mobile app closed and using desktop app -> edited a document on Desktop, document properly reflected in CouchDB changelog.
  • With desktop app closed and using mobile app -> let it sync .. document change does not reflect.
  • With desktop app closed and using mobile app -> tried to edit a different file and let it sync .. document change is not reflected in CouchDB changelog.

I tried to rollback both the versions of Desktop/Mobile to test the theory it's something in the new update, but the apps won't let me rollback even if I use the prior installs (I think it may pull the latest release even when installing using an older version).

edit2

One oddity is that I noticed the "Database Suffix" under "Hatch" is set to a generated string on Desktop. This was always empty before this week. If I reset it to something else, it always go back to that same generated string (even if I do it before initializing the db).

On the mobile app, it always reflects the vault name. Same issues apply when trying to rename. There's no documentation on this setting, so I'm not sure if they have to be different or if they're supposed to be the same. No matter what, I can't get them to use the same value on the same database.

When I get home I'll likely set it up on another Windows desktop and see if that exhibits the same behavior or if it successfully syncs. If it does, then it would seem to be a mobile issue.

kylek29 avatar Feb 27 '24 18:02 kylek29

It's be helpful if the actual error could be pushed to the log. Because the log can be viewed on mobile without any hassle. It's frustrating to not know whether it's a boring 404, or some certificate error, or a network failure of sorts. No idea. Not even a clue. Shouldn't be that hard to put at least something in the log, right?

@kylek29 The problem in my case is that the server just simply cannot be reached (for unknown reason) so any configuration or credentials on CouchDB is irrelevant in my scenario.

thany avatar Feb 28 '24 12:02 thany

I am experiencing the same issue. I use a local DNS name for my database, only available on my DNS server. When I go to the database using the DNS name in a browser, all is fine. When I Sync tries to connect, the log writes:

Could not connect to http://<my local dns name>:<port>/<table> TypeError:Load failed

When I change the DNS name for the local IP address, all works fine...

I checked my DNS and could not find the DNS lookup for the specific domain by my mobile, but maybe I just overlooked it.

Edit: In my case it's on iOS by the way

Recte avatar Feb 28 '24 13:02 Recte

The problem in my case is that the server just simply cannot be reached

I didn't mention it specifically, but I did get one notification of "Network Issue" on mobile. I'm not sure if iPhone allows you to do this like Android, but you can download and manually install the Obsidian Dev Tools plugin from here: https://github.com/KjellConnelly/obsidian-dev-tools --> it allows full access to the console like Desktop. It's not actively maintained, so I put some instructions here: https://github.com/KjellConnelly/obsidian-dev-tools/issues/8

There were a few LiveSync plugin updates pushed last night (0.22.9?) and my issue went away for now, so maybe give the update a try?

kylek29 avatar Feb 28 '24 17:02 kylek29

Latest update doesn't fix this.

thany avatar Feb 29 '24 08:02 thany

I am experiencing the same issue. I use a local DNS name for my database, only available on my DNS server. When I go to the database using the DNS name in a browser, all is fine. When I Sync tries to connect, the log writes:

Could not connect to http://<my local dns name>:<port>/<table> TypeError:Load failed

When I change the DNS name for the local IP address, all works fine...

I checked my DNS and could not find the DNS lookup for the specific domain by my mobile, but maybe I just overlooked it.

Edit: In my case it's on iOS by the way

I have the same issue on ipad and iphone.

Liujun3712 avatar Feb 29 '24 09:02 Liujun3712

I use a publicly available DNS name for my server, and indeed, on my laptop when away from home, it works perfectly fine.

thany avatar Feb 29 '24 10:02 thany

I have the same problem. Test Database Connection comes out with "could not connect to ....(TypeError:Load failed)" on iOS However it works on PC with the same config.

iclosed avatar Feb 29 '24 14:02 iclosed

I am getting similar error, I lost track of the plugin update that broke it on the iOS. It was working well few days ago, unfortunately now the connection to the server isn't established, even when the couchdb instance is working fine and is accessible on windows obsidian

alx-xlx avatar Feb 29 '24 20:02 alx-xlx

Sorry for being delayed! I think that this is caused by the limitations of iOS 17; which are reported also by other plug-ins.

Please wait for the official position to be confirmed or use public DNS and certificates like @thany In earlier days, I have previously addressed this foreseen issue and posted a feature request. And it also appears to have received renewed attention.

I hope that the situation will be better.

P.S. Originally, I would like to write replies one at a time, but as my appearance has been very late and the story is progressing with your help, I have added the most important topics from this Issue to the Tips and troubleshooting. Please read this one as well.

vrtmrz avatar Mar 01 '24 00:03 vrtmrz

Sorry for being delayed! I think that this is caused by the limitations of iOS 17; which are reported also by other plug-ins.

I can confirm it's on iPadOS17 and iOS16. And for the record, in my case it works on Obsidian Windows and fails on mobile. On mobile it works when I enter the local IP address but not when I use the (local/internal) DNS name, which works fine on Windows.

Recte avatar Mar 01 '24 05:03 Recte

@thany @vrtmrz

I have the same problem. After some testing, the problem was resolved successfully in both Desktop App (Mac, Windows) and Mobile App (Android, Ipad).

The likely cause is that there are restrictions on http (non-secure) access to the app on the mobile OS. Therefore, after working on https support, everything was accessible from couchdb.

Previously, in the desktop app, you could access couchdb's ip (e.g. local: 192.168.1.100, isp: 123.123.123.123:5684) and hostname (e.g. http://myhostname.com:5684), but you could not access it by hostname only on mobile. (Internal IP and external IP were available)

So, I set the subdomain to couchdb.myhostname.com, obtained a let's encryted certificate for it, set up reverse-proxy, and accessed https://couchdb.myhostname.com, and both Desktop and Mobile were successful. ( Obsidian --> https://couchdb.myhostname.com --> reverse-proxy --> http://192.168.1.100:5984 )

Previously, when developing PWA, there was an issue where the mobile app could not access http (non secure), so I tested it and it worked well.

I hope this helps.

knighthell avatar Mar 01 '24 10:03 knighthell

@vrtmrz And what about my issue? It being the original issue and all... Certificates are not an issue in my scenario. Or at least they shouldn't be, as my server is on HTTPS with a publicly trusted certificate by Letsencrypt.

@knighthell Yes that's exactly the setup that I have. Reverse proxy. And as said before: it works perfectly fine, both on desktop and in a mobile browser. If it works in a browser on mobile, but not in the app, how the hecko could my setup ever be the problem? Clearly the DB is reachable from my mobile device!

thany avatar Mar 01 '24 10:03 thany

@knighthell inspired me to fix this on my own setup, I wrote a post to help future people facing this issue.

@thany I'm not sure what your issue could be exactly. One thing I didn't get right at first was setting up my reverse proxy config. Obsidian uses the database name as the path (e.g. if your site is foo.bar and your database is sync you'll get pinged at foo.bar/sync). Could you share some more of your setup and maybe we can help debug?

telwell avatar Mar 12 '24 01:03 telwell

@telwell It has worked before. I just suddenly stopped working. I didn't touch my proxy setup.

But to repeat myself: I can access the database from a browser, using the exact same URL and credentials, on the same device. So the only variable is the app.

So what do you want me to share exactly?

thany avatar Mar 12 '24 11:03 thany

@thany If the connection is working and the only variable is the origin of the connection, it could be a CORS issue in your proxy.

How is the reverse proxy set up?

telwell avatar Mar 12 '24 12:03 telwell

It is not a CORS issue. It is working perfectly on Obsidian desktop.

Also a CORS issue gives a different error, both when trying to sync and when testing connection in the settings.

But to answer your question, if you must know my reverse proxy config:

<VirtualHost *:80>
  ServerAdmin [email protected]
  ServerName couch.domainname.nl
  ProxyPass / http://unraid:5384/
  ProxgPassReverse / http://unraid:5384/
  ErrorLog log
  RewriteEngine on
  RewriteCond %{SERVER_NAME} =couch.domainname.nl
  RewriteRule ^ https://%{SERVER-NAME}%{REQUEST-URI} [END,NE,R=permanent]
</VirtualHost>

("domainname" is not real, it's just to protect my privacy)

thany avatar Mar 12 '24 15:03 thany

I also get the same problem, that it couldn't conned to the server. I found it only could't work on iphone, but could work in my ipad suscessly. So i think the problem only happen on "iphone".

leon80148 avatar Mar 13 '24 15:03 leon80148

Not only iPhone, I'm on Android.

Also I've tried it on non-secure HTTP and it gives the same error, which rules out any SSL/TLS misconfiguration (as expected, since, again, it works fine in any browser and on the desktop application)

thany avatar Mar 14 '24 10:03 thany

Adding some more Feedback here myself: iOS does not work. Checked that Certificate is working (LetsEncrypt, HTTPS Connection does work). Working from my Ipad, Mac and WIndows machine I have no issues. Only my iPhone doesn't connect. Reinstalling obsidian and reconfiguring the plugin did not fix the issue as well.

Fluxstone avatar Mar 14 '24 10:03 Fluxstone

I think we need to collect a lot of cases for fix. This is my testing environment.

Test OS : MacOS, Windows, Android, IPadOS couchdb version : 3.3.3 (using docker)

problems The reason why I fixed this problem was that I first tested it on the internal network and there was no problem, so I tested it through the domain and the problem occurred because the mobile device could not synchronize.

In my case, On the internal network, ALL OS worked well.(e.g. internal couchdb ip : 192.168.1.100:5984) I think that if everything works normally when tested on the internal network, obsidian and plugins can be considered normal.

and

using domain( URI : http://myhostname.com:5984 using nginx reverse proxy), MacOS and Windows ware successful but, It failed on iPadOS and Android. http://myhostname.com points to http://192.168.1.100 Error Message was "Connection Failed"

so, I applied HTTPS subdomain(using Let's Encrypted and nginx reverce proxy) couchdb.myhostname.com https://couchdb.myhostname.com points to http://192.168.1.100:5984 and now successful about ALL OS

This is my case.

knighthell avatar Mar 14 '24 14:03 knighthell

@telwell It has worked before. I just suddenly stopped working. I didn't touch my proxy setup.

But to repeat myself: I can access the database from a browser, using the exact same URL and credentials, on the same device. So the only variable is the app.

So what do you want me to share exactly?

I'm having this exact issue as well. It worked one day on my iPhone and the next day it just stopped working. I didn't change any settings and it continues to work on desktop, but the app just doesn't want to work for whatever reason.

Also in case it's important, my logs show the same generic error message "TypeError: Load failed".

joshmcorreia avatar Mar 15 '24 06:03 joshmcorreia

Sorry for the long absence!

As you all have mentioned, this is the problem of our hosts having to have a certificate now. And if they try to loosen this, I think they will be very careful in their decision. It is reasonable. (Of course, some believe that self-signed certificates are not a bad idea as long as they are stored in the local certificate store).

The solution of @telwell would be nice. This might be the best way to handle this. Another (and a bit easier, but less independent) solution can be using Cloudflare Tunnel.

@thany

Your confusion is very understandable. More I am weak in Apache...

We need a bit more configuration. Please refer to the official doc. If there are no nocanon on ProxyPass and no ProxyPreserveHost, which possibly is apart from the reason it is mentioned, a CORS error may eventually occur.

vrtmrz avatar Mar 15 '24 07:03 vrtmrz

Your confusion is very understandable. More I am weak in Apache...

We need a bit more configuration. Please refer to the official doc. If there are no nocanon on ProxyPass and no ProxyPreserveHost, which possibly is apart from the reason it is mentioned, a CORS error may eventually occur.

I really don't think my proxy config is the issue here. I keep repeating myself, but the exact same url with credentials works fine on a browser on the same device and while still on the same network.

Also, again, CORS is not the issue: Obsidian on desktop is also picky when it comes to CORS, and it is working fine - this proves to me that neither the proxy configuration, nor the CORS configuration, nor any other couchdb configuration could be the problem. Also the mobile app acts as if the server is totally unreachable (I think) so it doesn't even have a chance yet to report any CORS error, because for that it needs to "see" the server first.

thany avatar Mar 15 '24 08:03 thany

Oh, I beg your pardon! I had forgotten some!

If we cannot get a connection even though setting it up with HTTPS, we need to check what errors you're actually getting in DevTools. (It is opaque to Obsidian and Self-hosted LiveSync). Could you please check the log of DevTools on Android? Remote debug Android devices might be useful. (Also our DevTools guide is here).

vrtmrz avatar Mar 15 '24 09:03 vrtmrz

Could you (also) add more details to the regular log please? Asking users to install developer tools is okay(-ish) for now, but should not be neccesary going forward, after having solved this issue.

thany avatar Mar 16 '24 21:03 thany

Hello. Sorry for a question rather than a feedback, but did anyone get success running HTTPS with self-signed certificate on server and adding self-signed root certificate to trusted on IOS?

I'm using this plugin to sync with my DMZ network and I don't want to use public certificate authorities. Self-signer root+server is working for other things but I don't know if it would work for live sync.

UPDATE IOS version works perfectly with self-signed certificate if root certificate is trusted on device.

slonoed avatar Mar 18 '24 23:03 slonoed

Hi everyone, as far as I understand the problem with the iOS version is it requires https instead of HTTP. Are you working on a way to keep using HTTP or is there any guide on how to set up https starting from the HTTP version? Thank you in advance!

PS: I'm having the same issue. If you need me to collect some logs or anything else count me in.

NerusSkyhigh avatar Mar 19 '24 08:03 NerusSkyhigh

@slonoed You can use Letsencrypt. But more to the point: it's a totally different issue.

thany avatar Mar 19 '24 09:03 thany

So I used the remote debugging tool:

localhost/:1 Access to fetch at 'https://couch.mydomain.nl/obsidian/' from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

So it is a CORS issue. Well then.

  1. Why did this start happening "suddenly"?
  2. Why does this NOT occur on desktop, which also requires CORS to be enabled?
  3. Why is the origin http://localhost? This needs to be a recognisable identifier.

3 is probably what answers 2, and it is probably also what's changed from when it used to work.

CORS configuration is like this: image

Adding localhost here is a security issue, since it would allow website running locally (on anyone's device!) to access the DB.

Not sure if this is a problem in Obsidian or LiveSync, so please collaborate on the solution.

thany avatar Mar 19 '24 09:03 thany