Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload from Anki desktop shows incorrect ID or password #108

Open
upsuper opened this issue Aug 21, 2021 · 16 comments
Open

Upload from Anki desktop shows incorrect ID or password #108

upsuper opened this issue Aug 21, 2021 · 16 comments

Comments

@upsuper
Copy link
Contributor

upsuper commented Aug 21, 2021

I'm trying Anki desktop 2.1.46, and syncing seems to go well, but when I do force uploading (either via ticking the "On next sync, force changes in one direction" on the Preferences, or doing something which requires that like removing a note type), it shows

AnkiWeb ID or password was incorrect; please try again.

and on the server side, the log shows

INFO:ankisyncd.http:127.0.0.1 "POST /sync/upload HTTP/1.1" 403 157

meanwhile if I trigger a force uploading from AnkiDroid, everything seems to be fine.

I've seen this mentioned in #54 and #97, but one is closed and another is marked "solved", however I couldn't find any clue on how this can be solved.

I've tried to pull the latest version of anki-sync-server, and tried upgrading the anki on the server to 2.1.44, but neither seems to help. (Upgrading anki to 2.1.46 makes the server fail to start, btw.)

@upsuper
Copy link
Contributor Author

upsuper commented Aug 21, 2021

I investigated into it a bit, and I'm suspecting that it's some issue on upstream, either Python's wsgiref or webob's wsgify.

I spinned up a local server, and have Anki desktop connect to it, and use Wireshark to capture the packets. It seems to me that the /sync/upload request to the server does contain the k as part of the multipart, but it doesn't seem to available inside SyncApp.__call__. Actually, that method got an empty req.params and req.POST.

@dobefore
Copy link
Contributor

Have you configured nginx?

@upsuper
Copy link
Contributor Author

upsuper commented Aug 21, 2021

It doesn't matter. I setup a local server and it fails exactly the same way.

@dobefore
Copy link
Contributor

dobefore commented Aug 21, 2021

Webob does not support the header "Transfer-Encoding: chunked" used by Anki and therefore ankisyncd sees chunked requests as empty

Is this causing your trouble?
this why nginx is necessary.

@upsuper
Copy link
Contributor Author

upsuper commented Aug 21, 2021

Hmm... okay. I guess that's the reason then. On my server I'm not using nginx but caddy, I guess it doesn't rewrite the request as needed.

@upsuper
Copy link
Contributor Author

upsuper commented Aug 21, 2021

It looks like Caddy doesn't really support reverse proxy to HTTP/1.0 and unchunk the request :(

Is there a plan to replace webob? This situation is really unfortunate... I don't really want to add another layer of reverse proxy just to make Anki desktop and the sync server work together...

@dobefore
Copy link
Contributor

dobefore commented Aug 21, 2021

Could you recommend an alternative? I'm not familiar with net-communication knowledge,We can try to work out together

@upsuper
Copy link
Contributor Author

upsuper commented Aug 21, 2021

I'm not very familiar with network development in Python unfortunately. It seems #21 suggested that maybe it could instead use Twisted.

I can probably help, but I would be hesitant to before someone from the project says they are open to accept such a change, as it's likely a nontrivial amount of time.

@dobefore
Copy link
Contributor

It surely require a lot of time,I may be of help if there is a plan

@upsuper
Copy link
Contributor Author

upsuper commented Aug 21, 2021

(FWIW, I eventually worked around it via using my local nginx server as a reverse proxy.)

@greengekota
Copy link

It looks like Caddy doesn't really support reverse proxy to HTTP/1.0 and unchunk the request :(

Caddy supports HTTP/1.0 and with enable_chunked_transfer_encoding_without_webserver it's solved. For the Caddyfile:

anki.cool.place {
        reverse_proxy localhost:27701 {
                transport http {
                        versions 1.0
                }
        }
}

@bitsf
Copy link

bitsf commented Dec 12, 2021

It looks like Caddy doesn't really support reverse proxy to HTTP/1.0 and unchunk the request :(

Caddy supports HTTP/1.0 and with enable_chunked_transfer_encoding_without_webserver it's solved. For the Caddyfile:

anki.cool.place {
        reverse_proxy localhost:27701 {
                transport http {
                        versions 1.0
                }
        }
}

this seems not worked

@greengekota
Copy link

this seems not worked

What is your setup? What is working, and what doesn't? If you do

curl --http1.0 https://anki.cool.place && echo ""

do you get "Anki Sync Server"? What is the error you're seeing?

@bitsf
Copy link

bitsf commented Dec 12, 2021

  • I tried nginx workaround, it works.
  • And I tried latest caddy version with below Caddyfile, it still report incorrect ID or password.
192.168.6.107:27702 {
        reverse_proxy localhost:27701 {
                transport http {
                        versions 1.0
                }
        }
}
  • And I finally tried this PR https://github.com/ankicommunity/anki-sync-server/pull/110, it works. And 2.1.49 also works with this PR.

@greengekota
Copy link

greengekota commented Dec 12, 2021

Yes, my comment was more on

Caddy doesn't really support reverse proxy to HTTP/1.0

in case other people wanted to use Caddy and were thinking this was a problem. There is still need for that PR to support chunked requests, as most reverse proxies don't have the unchunk functionality.

@goffi-contrib
Copy link

goffi-contrib commented Jan 19, 2022

Hello, just in case it might help somebody else, I've got the same issue after installing anki-bin and anki-sync-server-git for Arch's AUR, despite having server and NGINX running correctly. I found that the issue was due to incorrect value in the __init__.py of the plugin (/opt/anki-sync-server/plugins/anki2.1.28/anki-sync-server/__init__.py): the port was set to 27702 i.e. Anky Sync Server's one, instead of 27701 i.e. NGINX's one. After fixing it, it works as expected. I'll report that on AUR.

Thanks a lot for your work, I didn't wanted to use the proprietary server, and I'm really happy to have an alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants