-
Notifications
You must be signed in to change notification settings - Fork 254
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
Link device QR code fails with 412 M_CONCURRENT_WRITE #18155
Comments
@sandhose would you please check te log above, I don't see any problems with etag. |
I've tested MAS with completely new Synapse instance without workers with the same result. |
Seems login via QR doesn't work now even on beta.element.io, it worked fine few days back. It fails after timeout on the 6-letter confirmation code screen on Element X. |
This feels like there is a caching proxy in front of Synapse, or something that compresses on the fly. Do you happen to have Cloudflare in front of Synapse? Or nginx with |
@sandhose you are right, turning off gzip for Synapse on my nginx proxy did the trick, PUT forwards |
It's
You can build it locally with
That patch should make it unnecessary to exclude certain endpoint from compression |
I built docker image and deployed it to my test Synapse container (with gzip enabled), however it still returns 412 :( |
I tried that, and it looks like this can happen when the local session doesn't have access to the cross-signing key or isn't connected to the key backup
Can you check in your request logs in EW? Right after you display the QR code, you should see:
|
Here's a script I have to make sure a rendezvous implementation works correctly: # /// script
# requires-python = ">=3.12"
# dependencies = ["requests"]
# ///
import logging
from http.client import HTTPConnection
import requests
HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
base = "https://example.com" # CHANGE ME
response = requests.post(
f"{base}/_matrix/client/unstable/org.matrix.msc4108/rendezvous",
data="INIITIAL" * 128,
headers={"Content-Type": "text/plain"},
)
assert response.status_code == 201, response.status_code
session = response.json()["url"]
assert "ETag" in response.headers
etag = response.headers["ETag"]
response = requests.get(session, headers={"If-None-Match": etag})
assert response.status_code == 304, response.status_code
response = requests.get(session)
assert response.status_code == 200, response.status_code
assert response.text == "INIITIAL" * 128
assert response.headers["ETag"] == etag
response = requests.put(
session, data="UPDATED\n" * 128, headers={"If-Match": etag, "Content-Type": "text/plain"}
)
assert response.status_code == 202, response.status_code
assert "ETag" in response.headers
assert response.headers["ETag"] != etag If you have Change the 'base' with where Synapse is exposed |
|
With etag values visible... That was exactly my suspicions. |
This is super useful: I think this is because nginx will switch to |
Unfortunatelly...
|
I missed that before, looks like nginx still Do you have |
Unfortunately |
The workaround to force uncompressed response from Synapse's side would be header like: Anyway, why is uncompressed response required? Etags are the same, the only difference is the weak validator. |
Whilst this is true for nginx, it isn't the case for other implementations like Caddy, which output a strong ETag with
That's on the client side, right? I guess it would require a change on the MSC for that, I don't really like this workaround :( I don't really know how we could fix this on the Synapse side, other than asking people to check their reverse proxy config and disable compression |
Then nginx should be fixed. Will try to investigate...
Yes, it's client side, not Synapse as I wrote.
Disabling gzip for those enpoints works for me, I can live with that. However it would be good to document it, because it will be a problem for others when MAS is used widely. Thank you for helping me to investigate the issue. |
Description
I have set up MAS (with Authentik OIDC) on my Matrix instance, enabled MSC3861 and MSC4108 on Synapse according docs, everything looks good, login via Authentik works fine, however...
I want to add another Android device via QR code, when I scan QR code with Element X from Element Web following Element Web GET requests to
https://matrix.domain/_matrix/client/v3/devices/ZD6NzBC8RQ38jWLUIXBmQFPXB81etmMpbdD423%2F00BA
fails with 404{"errcode":"M_NOT_FOUND","error":"Not found"}
Not sure if this is expected.
After the 2-digit code from Element X is entered on Element Web folowing PUT request to
https://matrix.domain/_synapse/client/rendezvous/01JKWWGPR4N9YXYG6RCCY38H0W
fails with{"errcode":"M_UNKNOWN","error":"ETag does not match","org.matrix.msc4108.errcode":"M_CONCURRENT_WRITE"}
MAS request is confirmed and page closed, Element X stucks on that 2-digit code screen and fails after timeout same as Element Web.
What could be wrong there?
Are docs regarding worker settings up to date?
https://element-hq.github.io/synapse/develop/workers.html?highlight=workers#worker-configuration
Currently the
/_synapse/client/rendezvous/{id}
and/_matrix/client/v3/devices/{id}
endpoints are handled by master worker instead of client worker.Thanks.
EDIT: rolling back MAS, still unstable and broken...
Error: [{"message":"Database inconsistency on table compat_sessions column device_id row 01HQ3FB21QVAPX9E710P93212F","locations":[{"line":7,"column":7}],"path":["viewer","appSessions"]}]
while listing user account sessions
Steps to reproduce
above
Homeserver
Synapse
Synapse Version
1.124.0
Installation Method
Docker (matrixdotorg/synapse)
Database
Postgres 16
Workers
Multiple workers
Platform
Fedora 41
Configuration
No response
Relevant log output
Anything else that would be useful to know?
No response
The text was updated successfully, but these errors were encountered: