-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Matrix Well Known URI Server Discovery #1198
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1198 +/- ##
=======================================
Coverage 99.35% 99.35%
=======================================
Files 147 147
Lines 20320 20414 +94
Branches 3979 3995 +16
=======================================
+ Hits 20189 20283 +94
Misses 121 121
Partials 10 10 ☔ View full report in Codecov by Sentry. |
Thanks for tackling this issue. This will not work because you mixed up the SRV delegation with the well-known delegation. My setup is using the well-known delegation and serves a JSON like the example from #1067. Additionally See the matrix spec for details on how to get the matrix server hostname. Finally everything I use that connects with matrix, seems to use that spec and figure out the actual server to connect to without any need to specify delegation and I think therefore |
@bwachtendorf : Your feedback is incredible; thank you! I'm not keen on all the overhead invovled with delegate being enabled by defaut as you're the first one to open a ticket on the situation. I am under the impression (but i could very well be wrong 😉 ) that not many people use it. I did switch the default to be I very much value your feedback so please let me know your thoughts. |
50d8e36
to
e5b5c87
Compare
I just tested it with with following results:
dig result:
Maybe you could query |
@bwachtendorf I didn't forget about this request; it just turned out to be so much bigger then i thought it would be. I very heavily added inline documentation to my code to make it easy to follow. Inline documentation follows the link you shared. I think I fixed the parsing for This last commit is a complete refactor of everthing.
I'm not sure if this works yet as i can't really test (i don't have a matrix server anymore, but i'll start researching how to get one going again). In the mean-time i still pulled off 100% test coverage without disrupting the working code and their testing... hence there is a good chance this may work (and if not, there won't be too much left to update)... i hope 🙏 I also want to add that i really appreciate your testing and all your great feedback after my last commit 🚀 |
So just some quick tests because it's late here:
|
With the latest changes:
|
Enjoy your sleep! 🙏 I think i'm going to need to work offline with you a bit here. Can you send me an email to [email protected] and/or log into Discord? This one has me baffled as the If the |
eb260f2
to
54c241e
Compare
@bwachtendorf I think I got it. Give it another go and let me know. |
First off. It works!
I got rate limited by my own server quickly while testing:
Without:
In my opinion the process should look like this:
That would be max. 5 requests and not 9 like it is now. When hitting something in the cache it should require just 1 request and not 3. |
Thank you for checking and responding so quickly!
I'm quite shocked and I apologize for all of the extra web requests. I'm
surprised the cache isn't being referenced (i even have unit tests that
test that it stores correctly)... there is definitely something wrong.
I'll look back into this. Thank you for sharing all of your results!
…On Sat, Sep 14, 2024 at 5:15 PM Björn Wachtendorf ***@***.***> wrote:
First off. It works!
But there are still some minor problems.
1. It does a lot of requests that are not necessary:
2024-09-14 22:39:04,984 - DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.0733s
2024-09-14 22:39:04,985 - DEBUG - Loaded Matrix URL: matrixs://<username>:****@<domain>/<room_id>?image=no&mode=off&version=3&msgtype=text&discovery=yes&format=text&overflow=upstream
2024-09-14 22:39:04,985 - DEBUG - Matrix GET URL: https://<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:39:04,985 - DEBUG - Matrix Payload: None
2024-09-14 22:39:04,989 - DEBUG - Matrix Response: code=200, b'{"m.<username>": {"base_url": "https://matrix.<domain>"}}'
2024-09-14 22:39:04,990 - DEBUG - Matrix GET URL: https://matrix.<domain>/_matrix/client/versions (cert_verify=True)
2024-09-14 22:39:04,990 - DEBUG - Matrix Payload: None
2024-09-14 22:39:04,995 - DEBUG - Matrix Response: code=200, b'{"versions":["r0.0.1","r0.1.0","r0.2.0","r0.3.0","r0.4.0","r0.5.0","r0.6.0","r0.6.1","v1.1","v1.2","v1.3","v1.4","v1.5","v1.6","v1.7","v1.8","v1.9","v1.10","v1.11"],"unstable_features":{"org.matrix.label_based_filtering":true,"org.matrix.e2e_cross_signing":true,"org.matrix.msc2432":true,"uk.half-shot.msc2666.query_mutual_rooms":true,"io.element.e2ee_forced.public":false,"io.element.e2ee_forced.private":false,"io.element.e2ee_forced.trusted_private":false,"org.matrix.msc3026.busy_presence":false,"org.matrix.msc2285.stable":true,"org.matrix.msc3827.stable":true,"org.matrix.msc3440.stable":true,"org.matrix.msc3771":true,"org.matrix.msc3773":false,"fi.mau.msc2815":false,"fi.mau.msc2659.stable":true,"org.matrix.msc3882":false,"org.matrix.msc3881":false,"org.matrix.msc3874":false,"org.matrix.msc3886":false,"org.matrix.msc3912":false,"org.matrix.msc3981":true,"org.matrix.msc3391":false,"org.matrix.msc4069":false,"org.matrix.msc4028":false,"org.matrix.msc4108":false,"org.matrix.msc4151":false,"org.matrix.simplified_msc3575":true}}'
2024-09-14 22:39:04,995 - DEBUG - Matrix POST URL: https://matrix.<domain>/_matrix/client/v3/login (cert_verify=True)
2024-09-14 22:39:04,995 - DEBUG - Matrix Payload: {'type': 'm.login.password', 'identifier': {'type': 'm.id.user', 'user': '<username>'}, 'password': '<password>'}
2024-09-14 22:39:05,254 - DEBUG - Matrix Response: code=200, b'{"user_id":"@<username>:<domain>","access_token":"<access_token>","home_server":"<domain>","device_id":"GRHSKNBHZA"}'
2024-09-14 22:39:05,254 - DEBUG - Authenticated successfully with Matrix server.
2024-09-14 22:39:05,254 - DEBUG - Matrix GET URL: https://<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:39:05,255 - DEBUG - Matrix Payload: None
2024-09-14 22:39:05,258 - DEBUG - Matrix Response: code=200, b'{"m.<username>": {"base_url": "https://matrix.<domain>"}}'
2024-09-14 22:39:05,259 - DEBUG - Matrix GET URL: https://matrix.<domain>/_matrix/client/versions (cert_verify=True)
2024-09-14 22:39:05,259 - DEBUG - Matrix Payload: None
2024-09-14 22:39:05,268 - DEBUG - Matrix Response: code=200, b'{"versions":["r0.0.1","r0.1.0","r0.2.0","r0.3.0","r0.4.0","r0.5.0","r0.6.0","r0.6.1","v1.1","v1.2","v1.3","v1.4","v1.5","v1.6","v1.7","v1.8","v1.9","v1.10","v1.11"],"unstable_features":{"org.matrix.label_based_filtering":true,"org.matrix.e2e_cross_signing":true,"org.matrix.msc2432":true,"uk.half-shot.msc2666.query_mutual_rooms":true,"io.element.e2ee_forced.public":false,"io.element.e2ee_forced.private":false,"io.element.e2ee_forced.trusted_private":false,"org.matrix.msc3026.busy_presence":false,"org.matrix.msc2285.stable":true,"org.matrix.msc3827.stable":true,"org.matrix.msc3440.stable":true,"org.matrix.msc3771":true,"org.matrix.msc3773":false,"fi.mau.msc2815":false,"fi.mau.msc2659.stable":true,"org.matrix.msc3882":false,"org.matrix.msc3881":false,"org.matrix.msc3874":false,"org.matrix.msc3886":false,"org.matrix.msc3912":false,"org.matrix.msc3981":true,"org.matrix.msc3391":false,"org.matrix.msc4069":false,"org.matrix.msc4028":false,"org.matrix.msc4108":false,"org.matrix.msc4151":false,"org.matrix.simplified_msc3575":true}}'
2024-09-14 22:39:05,268 - DEBUG - Matrix POST URL: https://matrix.<domain>/_matrix/client/v3/join/<room_id>%3A<domain> (cert_verify=True)
2024-09-14 22:39:05,268 - DEBUG - Matrix Payload: {}
2024-09-14 22:39:05,293 - DEBUG - Matrix Response: code=200, b'{"room_id":"<room_id>:<domain>"}'
2024-09-14 22:39:05,293 - DEBUG - Matrix GET URL: https://<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:39:05,293 - DEBUG - Matrix Payload: None
2024-09-14 22:39:05,297 - DEBUG - Matrix Response: code=200, b'{"m.<username>": {"base_url": "https://matrix.<domain>"}}'
2024-09-14 22:39:05,297 - DEBUG - Matrix GET URL: https://matrix.<domain>/_matrix/client/versions (cert_verify=True)
2024-09-14 22:39:05,297 - DEBUG - Matrix Payload: None
2024-09-14 22:39:05,303 - DEBUG - Matrix Response: code=200, b'{"versions":["r0.0.1","r0.1.0","r0.2.0","r0.3.0","r0.4.0","r0.5.0","r0.6.0","r0.6.1","v1.1","v1.2","v1.3","v1.4","v1.5","v1.6","v1.7","v1.8","v1.9","v1.10","v1.11"],"unstable_features":{"org.matrix.label_based_filtering":true,"org.matrix.e2e_cross_signing":true,"org.matrix.msc2432":true,"uk.half-shot.msc2666.query_mutual_rooms":true,"io.element.e2ee_forced.public":false,"io.element.e2ee_forced.private":false,"io.element.e2ee_forced.trusted_private":false,"org.matrix.msc3026.busy_presence":false,"org.matrix.msc2285.stable":true,"org.matrix.msc3827.stable":true,"org.matrix.msc3440.stable":true,"org.matrix.msc3771":true,"org.matrix.msc3773":false,"fi.mau.msc2815":false,"fi.mau.msc2659.stable":true,"org.matrix.msc3882":false,"org.matrix.msc3881":false,"org.matrix.msc3874":false,"org.matrix.msc3886":false,"org.matrix.msc3912":false,"org.matrix.msc3981":true,"org.matrix.msc3391":false,"org.matrix.msc4069":false,"org.matrix.msc4028":false,"org.matrix.msc4108":false,"org.matrix.msc4151":false,"org.matrix.simplified_msc3575":true}}'
2024-09-14 22:39:05,303 - DEBUG - Matrix <function put at 0x7fe5cdea36a0> URL: https://matrix.<domain>/_matrix/client/v3/rooms/<room_id>%3A<domain>/send/m.room.message/0 (cert_verify=True)
2024-09-14 22:39:05,303 - DEBUG - Matrix Payload: {'msgtype': 'm.text', 'body': 'test'}
2024-09-14 22:39:05,353 - DEBUG - Matrix Response: code=200, b'{"event_id":"$EnvXRoOiXIBdodMw9yzKxYl9kv431A2b0yggnsDSn7I"}'
I got rate limited by my own server quickly while testing:
2024-09-14 22:39:08,251 - DEBUG - Matrix Response: code=429, b'{"errcode":"M_LIMIT_EXCEEDED","error":"Too Many Requests","retry_after_ms":205563}'
2024-09-14 22:39:08,251 - WARNING - Matrix server requested we throttle back 205.563ms; retries left 1.
2. Using the correct domain directly requires ?discovery=no:
With discovery:
2024-09-14 22:38:13,207 - DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.0758s
2024-09-14 22:38:13,207 - DEBUG - Loaded Matrix URL: ***@***.***<domain>/<room_id>?image=no&mode=off&version=3&msgtype=text&discovery=yes&format=text&overflow=upstream
2024-09-14 22:38:13,207 - DEBUG - Matrix GET URL: https://matrix.<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:38:13,207 - DEBUG - Matrix Payload: None
2024-09-14 22:38:13,214 - DEBUG - Matrix Response: code=200, b''
2024-09-14 22:38:13,214 - WARNING - Invalid response from Matrix server.
2024-09-14 22:38:13,214 - DEBUG - Response Details:
b''
2024-09-14 22:38:13,214 - WARNING - Matrix Well-Known Base URI Discovery Failed - https://matrix.<domain>/.well-known/matrix/client returned error code: 500
2024-09-14 22:38:13,214 - DEBUG - Matrix GET URL: https://matrix.<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:38:13,214 - DEBUG - Matrix Payload: None
2024-09-14 22:38:13,219 - DEBUG - Matrix Response: code=200, b''
2024-09-14 22:38:13,219 - WARNING - Invalid response from Matrix server.
2024-09-14 22:38:13,219 - DEBUG - Response Details:
b''
2024-09-14 22:38:13,219 - WARNING - Matrix Well-Known Base URI Discovery Failed - https://matrix.<domain>/.well-known/matrix/client returned error code: 500
Without:
2024-09-14 22:38:47,166 - DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.0750s
2024-09-14 22:38:47,167 - DEBUG - Loaded Matrix URL: ***@***.***<domain>/<room_id>?image=no&mode=off&version=3&msgtype=text&discovery=no&format=text&overflow=upstream
2024-09-14 22:38:47,167 - DEBUG - Matrix POST URL: https://matrix.<domain>/_matrix/client/v3/login (cert_verify=True)
2024-09-14 22:38:47,167 - DEBUG - Matrix Payload: {'type': 'm.login.password', 'identifier': {'type': 'm.id.user', 'user': '<username>'}, 'password': '<password>'}
2024-09-14 22:38:47,432 - DEBUG - Matrix Response: code=200, b'{"user_id":"@<username>:<domain>","access_token":"<access_token>","home_server":"<domain>","device_id":"ZZISDVABGS"}'
2024-09-14 22:38:47,432 - DEBUG - Authenticated successfully with Matrix server.
2024-09-14 22:38:47,432 - DEBUG - Matrix POST URL: https://matrix.<domain>/_matrix/client/v3/join/<room_id>%3A<domain> (cert_verify=True)
2024-09-14 22:38:47,432 - DEBUG - Matrix Payload: {}
2024-09-14 22:38:47,459 - DEBUG - Matrix Response: code=200, b'{"room_id":"<room_id>:<domain>"}'
2024-09-14 22:38:47,460 - DEBUG - Matrix <function put at 0x7e13c02bf740> URL: https://matrix.<domain>/_matrix/client/v3/rooms/<room_id>%3A<domain>/send/m.room.message/0 (cert_verify=True)
2024-09-14 22:38:47,460 - DEBUG - Matrix Payload: {'msgtype': 'm.text', 'body': 'test'}
2024-09-14 22:38:47,512 - DEBUG - Matrix Response: code=200, b'{"event_id":"$A4iByAeZf2nYXamtff3o_LFcTMYJoTONENOphDFU7RI"}'
3. Caching does not seem to work correctly because apprise still tries
to discover the server that was just discovered, instead of just skipping
to the PUT query:
2024-09-14 22:43:31,436 - DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.0766s
2024-09-14 22:43:31,437 - DEBUG - Loaded Matrix URL: matrixs://<username>:****@<domain>/<room_id>?image=no&mode=off&version=3&msgtype=text&discovery=yes&format=text&overflow=upstream
2024-09-14 22:43:31,437 - DEBUG - Matrix GET URL: https://<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:43:31,437 - DEBUG - Matrix Payload: None
2024-09-14 22:43:31,442 - DEBUG - Matrix Response: code=200, b'{"m.<username>": {"base_url": "https://matrix.<domain>"}}'
2024-09-14 22:43:31,443 - DEBUG - Matrix GET URL: https://matrix.<domain>/_matrix/client/versions (cert_verify=True)
2024-09-14 22:43:31,443 - DEBUG - Matrix Payload: None
2024-09-14 22:43:31,448 - DEBUG - Matrix Response: code=200, b'{"versions":["r0.0.1","r0.1.0","r0.2.0","r0.3.0","r0.4.0","r0.5.0","r0.6.0","r0.6.1","v1.1","v1.2","v1.3","v1.4","v1.5","v1.6","v1.7","v1.8","v1.9","v1.10","v1.11"],"unstable_features":{"org.matrix.label_based_filtering":true,"org.matrix.e2e_cross_signing":true,"org.matrix.msc2432":true,"uk.half-shot.msc2666.query_mutual_rooms":true,"io.element.e2ee_forced.public":false,"io.element.e2ee_forced.private":false,"io.element.e2ee_forced.trusted_private":false,"org.matrix.msc3026.busy_presence":false,"org.matrix.msc2285.stable":true,"org.matrix.msc3827.stable":true,"org.matrix.msc3440.stable":true,"org.matrix.msc3771":true,"org.matrix.msc3773":false,"fi.mau.msc2815":false,"fi.mau.msc2659.stable":true,"org.matrix.msc3882":false,"org.matrix.msc3881":false,"org.matrix.msc3874":false,"org.matrix.msc3886":false,"org.matrix.msc3912":false,"org.matrix.msc3981":true,"org.matrix.msc3391":false,"org.matrix.msc4069":false,"org.matrix.msc4028":false,"org.matrix.msc4108":false,"org.matrix.msc4151":false,"org.matrix.simplified_msc3575":true}}'
2024-09-14 22:43:31,448 - DEBUG - Matrix <function put at 0x7dee2048f6a0> URL: https://matrix.<domain>/_matrix/client/v3/rooms/<room_id>%3A<domain>/send/m.room.message/2 (cert_verify=True)
2024-09-14 22:43:31,448 - DEBUG - Matrix Payload: {'msgtype': 'm.text', 'body': 'test'}
2024-09-14 22:43:31,527 - DEBUG - Matrix Response: code=200, b'{"event_id":"$FpH-IGZjKzbBhDWZhIDC-E1zeWfdgiask-udxH24oDI"}'
In my opinion the process should look like this:
1. Check cache
1. If we hit cache continue with 6
2. If we don't hit cache continue with 2
2. Check .well-known/matrix/client
1. If 200 with content continue with 3
2. Everything else continue with 4
3. Read delegation info from .well-known/matrix/client
4. Verify matrix server with _matrix/client/versions
5. Join room if not joined
6. Post message
That would be max. 5 requests and not 9 like it is now. When hitting
something in the cache it should require just 1 request and not 3.
—
Reply to this email directly, view it on GitHub
<#1198 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGPTRTNVH6T5UJGSDZPWSDZWSRPPAVCNFSM6AAAAABNOOADGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGE2TONZRGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Cache should be working now (latest push), and also if the upstream server
returns a 200 response code, but has no body, i won't treat it as
invalid/error. I'll simply cache that there is no discovery servers.
Give it another go! 🚀🙏
…On Sat, Sep 14, 2024 at 5:15 PM Björn Wachtendorf ***@***.***> wrote:
First off. It works!
But there are still some minor problems.
1. It does a lot of requests that are not necessary:
2024-09-14 22:39:04,984 - DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.0733s
2024-09-14 22:39:04,985 - DEBUG - Loaded Matrix URL: matrixs://<username>:****@<domain>/<room_id>?image=no&mode=off&version=3&msgtype=text&discovery=yes&format=text&overflow=upstream
2024-09-14 22:39:04,985 - DEBUG - Matrix GET URL: https://<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:39:04,985 - DEBUG - Matrix Payload: None
2024-09-14 22:39:04,989 - DEBUG - Matrix Response: code=200, b'{"m.<username>": {"base_url": "https://matrix.<domain>"}}'
2024-09-14 22:39:04,990 - DEBUG - Matrix GET URL: https://matrix.<domain>/_matrix/client/versions (cert_verify=True)
2024-09-14 22:39:04,990 - DEBUG - Matrix Payload: None
2024-09-14 22:39:04,995 - DEBUG - Matrix Response: code=200, b'{"versions":["r0.0.1","r0.1.0","r0.2.0","r0.3.0","r0.4.0","r0.5.0","r0.6.0","r0.6.1","v1.1","v1.2","v1.3","v1.4","v1.5","v1.6","v1.7","v1.8","v1.9","v1.10","v1.11"],"unstable_features":{"org.matrix.label_based_filtering":true,"org.matrix.e2e_cross_signing":true,"org.matrix.msc2432":true,"uk.half-shot.msc2666.query_mutual_rooms":true,"io.element.e2ee_forced.public":false,"io.element.e2ee_forced.private":false,"io.element.e2ee_forced.trusted_private":false,"org.matrix.msc3026.busy_presence":false,"org.matrix.msc2285.stable":true,"org.matrix.msc3827.stable":true,"org.matrix.msc3440.stable":true,"org.matrix.msc3771":true,"org.matrix.msc3773":false,"fi.mau.msc2815":false,"fi.mau.msc2659.stable":true,"org.matrix.msc3882":false,"org.matrix.msc3881":false,"org.matrix.msc3874":false,"org.matrix.msc3886":false,"org.matrix.msc3912":false,"org.matrix.msc3981":true,"org.matrix.msc3391":false,"org.matrix.msc4069":false,"org.matrix.msc4028":false,"org.matrix.msc4108":false,"org.matrix.msc4151":false,"org.matrix.simplified_msc3575":true}}'
2024-09-14 22:39:04,995 - DEBUG - Matrix POST URL: https://matrix.<domain>/_matrix/client/v3/login (cert_verify=True)
2024-09-14 22:39:04,995 - DEBUG - Matrix Payload: {'type': 'm.login.password', 'identifier': {'type': 'm.id.user', 'user': '<username>'}, 'password': '<password>'}
2024-09-14 22:39:05,254 - DEBUG - Matrix Response: code=200, b'{"user_id":"@<username>:<domain>","access_token":"<access_token>","home_server":"<domain>","device_id":"GRHSKNBHZA"}'
2024-09-14 22:39:05,254 - DEBUG - Authenticated successfully with Matrix server.
2024-09-14 22:39:05,254 - DEBUG - Matrix GET URL: https://<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:39:05,255 - DEBUG - Matrix Payload: None
2024-09-14 22:39:05,258 - DEBUG - Matrix Response: code=200, b'{"m.<username>": {"base_url": "https://matrix.<domain>"}}'
2024-09-14 22:39:05,259 - DEBUG - Matrix GET URL: https://matrix.<domain>/_matrix/client/versions (cert_verify=True)
2024-09-14 22:39:05,259 - DEBUG - Matrix Payload: None
2024-09-14 22:39:05,268 - DEBUG - Matrix Response: code=200, b'{"versions":["r0.0.1","r0.1.0","r0.2.0","r0.3.0","r0.4.0","r0.5.0","r0.6.0","r0.6.1","v1.1","v1.2","v1.3","v1.4","v1.5","v1.6","v1.7","v1.8","v1.9","v1.10","v1.11"],"unstable_features":{"org.matrix.label_based_filtering":true,"org.matrix.e2e_cross_signing":true,"org.matrix.msc2432":true,"uk.half-shot.msc2666.query_mutual_rooms":true,"io.element.e2ee_forced.public":false,"io.element.e2ee_forced.private":false,"io.element.e2ee_forced.trusted_private":false,"org.matrix.msc3026.busy_presence":false,"org.matrix.msc2285.stable":true,"org.matrix.msc3827.stable":true,"org.matrix.msc3440.stable":true,"org.matrix.msc3771":true,"org.matrix.msc3773":false,"fi.mau.msc2815":false,"fi.mau.msc2659.stable":true,"org.matrix.msc3882":false,"org.matrix.msc3881":false,"org.matrix.msc3874":false,"org.matrix.msc3886":false,"org.matrix.msc3912":false,"org.matrix.msc3981":true,"org.matrix.msc3391":false,"org.matrix.msc4069":false,"org.matrix.msc4028":false,"org.matrix.msc4108":false,"org.matrix.msc4151":false,"org.matrix.simplified_msc3575":true}}'
2024-09-14 22:39:05,268 - DEBUG - Matrix POST URL: https://matrix.<domain>/_matrix/client/v3/join/<room_id>%3A<domain> (cert_verify=True)
2024-09-14 22:39:05,268 - DEBUG - Matrix Payload: {}
2024-09-14 22:39:05,293 - DEBUG - Matrix Response: code=200, b'{"room_id":"<room_id>:<domain>"}'
2024-09-14 22:39:05,293 - DEBUG - Matrix GET URL: https://<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:39:05,293 - DEBUG - Matrix Payload: None
2024-09-14 22:39:05,297 - DEBUG - Matrix Response: code=200, b'{"m.<username>": {"base_url": "https://matrix.<domain>"}}'
2024-09-14 22:39:05,297 - DEBUG - Matrix GET URL: https://matrix.<domain>/_matrix/client/versions (cert_verify=True)
2024-09-14 22:39:05,297 - DEBUG - Matrix Payload: None
2024-09-14 22:39:05,303 - DEBUG - Matrix Response: code=200, b'{"versions":["r0.0.1","r0.1.0","r0.2.0","r0.3.0","r0.4.0","r0.5.0","r0.6.0","r0.6.1","v1.1","v1.2","v1.3","v1.4","v1.5","v1.6","v1.7","v1.8","v1.9","v1.10","v1.11"],"unstable_features":{"org.matrix.label_based_filtering":true,"org.matrix.e2e_cross_signing":true,"org.matrix.msc2432":true,"uk.half-shot.msc2666.query_mutual_rooms":true,"io.element.e2ee_forced.public":false,"io.element.e2ee_forced.private":false,"io.element.e2ee_forced.trusted_private":false,"org.matrix.msc3026.busy_presence":false,"org.matrix.msc2285.stable":true,"org.matrix.msc3827.stable":true,"org.matrix.msc3440.stable":true,"org.matrix.msc3771":true,"org.matrix.msc3773":false,"fi.mau.msc2815":false,"fi.mau.msc2659.stable":true,"org.matrix.msc3882":false,"org.matrix.msc3881":false,"org.matrix.msc3874":false,"org.matrix.msc3886":false,"org.matrix.msc3912":false,"org.matrix.msc3981":true,"org.matrix.msc3391":false,"org.matrix.msc4069":false,"org.matrix.msc4028":false,"org.matrix.msc4108":false,"org.matrix.msc4151":false,"org.matrix.simplified_msc3575":true}}'
2024-09-14 22:39:05,303 - DEBUG - Matrix <function put at 0x7fe5cdea36a0> URL: https://matrix.<domain>/_matrix/client/v3/rooms/<room_id>%3A<domain>/send/m.room.message/0 (cert_verify=True)
2024-09-14 22:39:05,303 - DEBUG - Matrix Payload: {'msgtype': 'm.text', 'body': 'test'}
2024-09-14 22:39:05,353 - DEBUG - Matrix Response: code=200, b'{"event_id":"$EnvXRoOiXIBdodMw9yzKxYl9kv431A2b0yggnsDSn7I"}'
I got rate limited by my own server quickly while testing:
2024-09-14 22:39:08,251 - DEBUG - Matrix Response: code=429, b'{"errcode":"M_LIMIT_EXCEEDED","error":"Too Many Requests","retry_after_ms":205563}'
2024-09-14 22:39:08,251 - WARNING - Matrix server requested we throttle back 205.563ms; retries left 1.
2. Using the correct domain directly requires ?discovery=no:
With discovery:
2024-09-14 22:38:13,207 - DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.0758s
2024-09-14 22:38:13,207 - DEBUG - Loaded Matrix URL: ***@***.***<domain>/<room_id>?image=no&mode=off&version=3&msgtype=text&discovery=yes&format=text&overflow=upstream
2024-09-14 22:38:13,207 - DEBUG - Matrix GET URL: https://matrix.<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:38:13,207 - DEBUG - Matrix Payload: None
2024-09-14 22:38:13,214 - DEBUG - Matrix Response: code=200, b''
2024-09-14 22:38:13,214 - WARNING - Invalid response from Matrix server.
2024-09-14 22:38:13,214 - DEBUG - Response Details:
b''
2024-09-14 22:38:13,214 - WARNING - Matrix Well-Known Base URI Discovery Failed - https://matrix.<domain>/.well-known/matrix/client returned error code: 500
2024-09-14 22:38:13,214 - DEBUG - Matrix GET URL: https://matrix.<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:38:13,214 - DEBUG - Matrix Payload: None
2024-09-14 22:38:13,219 - DEBUG - Matrix Response: code=200, b''
2024-09-14 22:38:13,219 - WARNING - Invalid response from Matrix server.
2024-09-14 22:38:13,219 - DEBUG - Response Details:
b''
2024-09-14 22:38:13,219 - WARNING - Matrix Well-Known Base URI Discovery Failed - https://matrix.<domain>/.well-known/matrix/client returned error code: 500
Without:
2024-09-14 22:38:47,166 - DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.0750s
2024-09-14 22:38:47,167 - DEBUG - Loaded Matrix URL: ***@***.***<domain>/<room_id>?image=no&mode=off&version=3&msgtype=text&discovery=no&format=text&overflow=upstream
2024-09-14 22:38:47,167 - DEBUG - Matrix POST URL: https://matrix.<domain>/_matrix/client/v3/login (cert_verify=True)
2024-09-14 22:38:47,167 - DEBUG - Matrix Payload: {'type': 'm.login.password', 'identifier': {'type': 'm.id.user', 'user': '<username>'}, 'password': '<password>'}
2024-09-14 22:38:47,432 - DEBUG - Matrix Response: code=200, b'{"user_id":"@<username>:<domain>","access_token":"<access_token>","home_server":"<domain>","device_id":"ZZISDVABGS"}'
2024-09-14 22:38:47,432 - DEBUG - Authenticated successfully with Matrix server.
2024-09-14 22:38:47,432 - DEBUG - Matrix POST URL: https://matrix.<domain>/_matrix/client/v3/join/<room_id>%3A<domain> (cert_verify=True)
2024-09-14 22:38:47,432 - DEBUG - Matrix Payload: {}
2024-09-14 22:38:47,459 - DEBUG - Matrix Response: code=200, b'{"room_id":"<room_id>:<domain>"}'
2024-09-14 22:38:47,460 - DEBUG - Matrix <function put at 0x7e13c02bf740> URL: https://matrix.<domain>/_matrix/client/v3/rooms/<room_id>%3A<domain>/send/m.room.message/0 (cert_verify=True)
2024-09-14 22:38:47,460 - DEBUG - Matrix Payload: {'msgtype': 'm.text', 'body': 'test'}
2024-09-14 22:38:47,512 - DEBUG - Matrix Response: code=200, b'{"event_id":"$A4iByAeZf2nYXamtff3o_LFcTMYJoTONENOphDFU7RI"}'
3. Caching does not seem to work correctly because apprise still tries
to discover the server that was just discovered, instead of just skipping
to the PUT query:
2024-09-14 22:43:31,436 - DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.0766s
2024-09-14 22:43:31,437 - DEBUG - Loaded Matrix URL: matrixs://<username>:****@<domain>/<room_id>?image=no&mode=off&version=3&msgtype=text&discovery=yes&format=text&overflow=upstream
2024-09-14 22:43:31,437 - DEBUG - Matrix GET URL: https://<domain>/.well-known/matrix/client (cert_verify=True)
2024-09-14 22:43:31,437 - DEBUG - Matrix Payload: None
2024-09-14 22:43:31,442 - DEBUG - Matrix Response: code=200, b'{"m.<username>": {"base_url": "https://matrix.<domain>"}}'
2024-09-14 22:43:31,443 - DEBUG - Matrix GET URL: https://matrix.<domain>/_matrix/client/versions (cert_verify=True)
2024-09-14 22:43:31,443 - DEBUG - Matrix Payload: None
2024-09-14 22:43:31,448 - DEBUG - Matrix Response: code=200, b'{"versions":["r0.0.1","r0.1.0","r0.2.0","r0.3.0","r0.4.0","r0.5.0","r0.6.0","r0.6.1","v1.1","v1.2","v1.3","v1.4","v1.5","v1.6","v1.7","v1.8","v1.9","v1.10","v1.11"],"unstable_features":{"org.matrix.label_based_filtering":true,"org.matrix.e2e_cross_signing":true,"org.matrix.msc2432":true,"uk.half-shot.msc2666.query_mutual_rooms":true,"io.element.e2ee_forced.public":false,"io.element.e2ee_forced.private":false,"io.element.e2ee_forced.trusted_private":false,"org.matrix.msc3026.busy_presence":false,"org.matrix.msc2285.stable":true,"org.matrix.msc3827.stable":true,"org.matrix.msc3440.stable":true,"org.matrix.msc3771":true,"org.matrix.msc3773":false,"fi.mau.msc2815":false,"fi.mau.msc2659.stable":true,"org.matrix.msc3882":false,"org.matrix.msc3881":false,"org.matrix.msc3874":false,"org.matrix.msc3886":false,"org.matrix.msc3912":false,"org.matrix.msc3981":true,"org.matrix.msc3391":false,"org.matrix.msc4069":false,"org.matrix.msc4028":false,"org.matrix.msc4108":false,"org.matrix.msc4151":false,"org.matrix.simplified_msc3575":true}}'
2024-09-14 22:43:31,448 - DEBUG - Matrix <function put at 0x7dee2048f6a0> URL: https://matrix.<domain>/_matrix/client/v3/rooms/<room_id>%3A<domain>/send/m.room.message/2 (cert_verify=True)
2024-09-14 22:43:31,448 - DEBUG - Matrix Payload: {'msgtype': 'm.text', 'body': 'test'}
2024-09-14 22:43:31,527 - DEBUG - Matrix Response: code=200, b'{"event_id":"$FpH-IGZjKzbBhDWZhIDC-E1zeWfdgiask-udxH24oDI"}'
In my opinion the process should look like this:
1. Check cache
1. If we hit cache continue with 6
2. If we don't hit cache continue with 2
2. Check .well-known/matrix/client
1. If 200 with content continue with 3
2. Everything else continue with 4
3. Read delegation info from .well-known/matrix/client
4. Verify matrix server with _matrix/client/versions
5. Join room if not joined
6. Post message
That would be max. 5 requests and not 9 like it is now. When hitting
something in the cache it should require just 1 request and not 3.
—
Reply to this email directly, view it on GitHub
<#1198 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGPTRTNVH6T5UJGSDZPWSDZWSRPPAVCNFSM6AAAAABNOOADGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRGE2TONZRGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I don't see any more problems on my end. Everything works now as I would expect it. |
Before i merge; is it worth bumping up the cache to say 30 days before searching for the well-known entry again, or leave it at 1 day ? I just don't want to create more web hits than necessary. Thoughts? |
I think 24 hours is OK, otherwise we might run into problems, where the cache has to be manually deleted because of old values. |
Description:
Related issue (if applicable): #1067
Matrix Server Delegation Added.
If you set
?delegate=yes
on the Apprisematrix://
URL, A DNSSRV
query is made to_matrix._tcp.your-host
to acquire a Delegated server. If one is found, thenm.server
parameters are added into all matrix subsequent calls.@bwachtendorf, I would really love your feedback on this one 🙏
Checklist
flake8
)Testing
Anyone can help test this source code as follows: