anki-sync-server
anki-sync-server copied to clipboard
Ankidroid can't connect to anki-sync-server
I've setup anki-sync-server, opened the port 27701 on my router, manage to sync my laptop Anki to the server using the internet ip. I can also access the server from my android's browser and see the message "Anki Sync Server" But when I try syncing from the phone, it failed with the following error:

From the readme:
AnkiDroid Advanced → Custom sync server
Unless you have set up a reverse proxy to handle encrypted connections, use http as the protocol. The port will be either the default, 27701, or whatever you have specified in ankisyncd.conf (or, if using a reverse proxy, whatever port you configured to accept the front-end connection).
Do not use trailing slashes.
It looks like http isn't supported by default on android https://better-coding.com/solved-android-cannot-send-data-to-the-server-cleartext-communication-to-not-permitted-by-network-security-policy/
Switching back to ankidroid verion 2.9 can solve it
Both of those two bits of information are very interesting! Forcing HTTPS is going to be more and more of an issue, no matter how much it annoys some people. Let's Encrypt is getting really easy to use now though, so this should be less of a hassle going forward.
I talked to the AnkiDroid guys and from version 2.10+ they want people to switch to SSL:

I took a look at #22 and set up my own reverse proxy, which cleared up the clear text issue. There are various ways to do so. I set mine up on AWS with a signed certificate from Let's Encrypt but I believe you might be able to use a self-signed one as well.
It seems Ankidroid (version:2.10.4 )can work without ssl.That is,It can run with http. I tested it just now!
For local https mkcert is an easy way to create self-signed CA to allow Ankidroid to sync with https
For local https
mkcertis an easy way to create self-signed CA to allow Ankidroid to sync with https
I run it on my PC with the Anki desktop folder, using the command: mkcert -install mkcert rootCA
Then I put the rootCA.pem file in my Android 9 phone, install the certificate for VPN/apps in the settings and reboot the phone. I am unable to install the file «rootCA-key.pem». Unfortunetely, this method does not allow me to sync with https. I then downloaded and installed Ankidroid 2.9.
@dobefore Sorry to everyone for digging this problem. Now that Anki desktop has a builtin sync server, is there a way to make Ankidroid sync with it?
If I first upload my Anki Desktop 2.0.52 collection then try to download with Ankidroid 2.9 version using http it says 400: BAD REQUEST. The same happens if I upload with Ankidroid 2.9 and try to download with Anki desktop 2.0.52.
When try with https it does the same as the writer of this issue has posted.
I think the network security policy is completely unnecessary.
I run my self-hosted anki-sync-server and have access via WireGuard. That is, with my VPN cert set up, I can guarantee secure connection via http://192.168.2.200:27701.
Having compulsory TLS connection will resulting double cert encrypt & decrypt in my situation. Also, it is inconvenient to obtain a cert for an ip like 192.168.2.200.
I admit TLS should be a must for any public web services. But in my case, I never intend for opening to public, therefore such policy cause trouble to me.