ulyssa / iamb

A Matrix client for Vim addicts
https://iamb.chat
Apache License 2.0
677 stars 46 forks source link

"the server returned an error: [404] <non-json bytes>" #338

Open ahs3 opened 3 months ago

ahs3 commented 3 months ago

Any clues as to what the message in the title means?

To reproduce this, I have removed ~/.config/iamb, ~/.local/share/iamb, and ~/.cache/iamb -- just like it would be if I had never run iamb before. With a sufficient timeout, I can sync up my matrix account with fedora.im. I can see rooms and spaces and such -- it all looks quite nice, really; thank you!

However, if I quit iamb, and then run it again, I get the following:

$ ~/projects/iamb/target/debug/iamb

If I remove all the files again, I can sync up again, but have to go through the SSO process again. And if I quit iamb, I'm back to .

I've attached a debug log but with my matrix account redacted. I would dig further, but I'm still a rust n00b.

iamb-log-2024-08-23.txt

ahs3 commented 3 months ago

additional info: no verification had taken place; however, even if verification was successful, and the final tab is :quit, I get the same message

ulyssa commented 3 months ago

It looks like there may be something odd going on with which server it's trying to connect to. I can see that it's getting back 404 responses from chat.fedoraproject.org

% grep '\<404\>' iamb-log-2024-08-23.txt | less
2024-08-23T22:46:43.648650Z DEBUG send{server_versions=[V1_0, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8] config=RequestConfig { timeout: 120s, retry_timeout: 120s } request_id="REQ-1" method=GET uri="https://chat.fedoraproject.org/_matrix/client/v3/user/@redacted:server/account_data/m.secret_storage.default_key" status=404 response_size="153 B"}: matrix_sdk::http_client: Error while sending request: Api(Server(ClientApi(Error { status_code: 404, body: NotJson { bytes: b"<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.27.1</center>\r\n</body>\r\n</html>\r\n", deserialization_error: Error("expected value", line: 1, column: 1) } })))
2024-08-23T22:46:43.648927Z ERROR matrix_sdk::encryption: Couldn't setup and resume recovery Sdk(Http(Api(Server(ClientApi(Error { status_code: 404, body: NotJson { bytes: b"<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.27.1</center>\r\n</body>\r\n</html>\r\n", deserialization_error: Error("expected value", line: 1, column: 1) } })))))
2024-08-23T22:46:43.654046Z DEBUG sync_with_callback:sync_with_result_callback{sync_settings=SyncSettings { timeout: 30s, full_state: false, set_presence: "online" }}:sync_once{sync_settings=SyncSettings { timeout: 30s, full_state: false, set_presence: "online" }}:send{server_versions=[V1_0, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8] config=RequestConfig { timeout: 150s, retry_timeout: 120s } request_id="REQ-3" method=GET uri="https://chat.fedoraproject.org/_matrix/client/v3/sync" status=404 response_size="153 B"}: matrix_sdk::http_client: Error while sending request: Api(Server(ClientApi(Error { status_code: 404, body: NotJson { bytes: b"<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.27.1</center>\r\n</body>\r\n</html>\r\n", deserialization_error: Error("expected value", line: 1, column: 1) } })))
2024-08-23T22:46:43.654259Z ERROR sync_with_callback:sync_with_result_callback{sync_settings=SyncSettings { timeout: 30s, full_state: false, set_presence: "online" }}: matrix_sdk::sync: Received an invalid response: the server returned an error: [404] <non-json bytes>
2024-08-23T22:46:43.654208Z DEBUG sync_once{sync_settings=SyncSettings { filter: FilterDefinition(FilterDefinition { event_fields: None, event_format: "client", presence: Filter { not_types: [], limit: None, senders: None, types: None, not_senders: [] }, account_data: Filter { not_types: [], limit: None, senders: None, types: None, not_senders: [] }, room: RoomFilter { include_leave: false, account_data: RoomEventFilter { not_types: [], not_rooms: [], limit: None, rooms: None, not_senders: [], senders: None, types: None, url_filter: None, lazy_load_options: Disabled, unread_thread_notifications: false }, timeline: RoomEventFilter { not_types: [], not_rooms: [], limit: None, rooms: None, not_senders: [], senders: None, types: None, url_filter: None, lazy_load_options: Disabled, unread_thread_notifications: false }, ephemeral: RoomEventFilter { not_types: [], not_rooms: [], limit: None, rooms: None, not_senders: [], senders: None, types: None, url_filter: None, lazy_load_options: Disabled, unread_thread_notifications: false }, state: RoomEventFilter { not_types: [], not_rooms: [], limit: None, rooms: None, not_senders: [], senders: None, types: None, url_filter: None, lazy_load_options: Enabled { include_redundant_members: false }, unread_thread_notifications: false }, not_rooms: [], rooms: None } }), timeout: 30s, full_state: false, set_presence: "online" }}:send{server_versions=[V1_0, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8] config=RequestConfig { timeout: 150s, retry_timeout: 120s } request_id="REQ-2" method=GET uri="https://chat.fedoraproject.org/_matrix/client/v3/sync" status=404 response_size="153 B"}: matrix_sdk::http_client: Error while sending request: Api(Server(ClientApi(Error { status_code: 404, body: NotJson { bytes: b"<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.27.1</center>\r\n</body>\r\n</html>\r\n", deserialization_error: Error("expected value", line: 1, column: 1) } })))

But it looks like that's not the right Matrix homeserver URL:

% curl https://fedoraproject.org/.well-known/matrix/client
{  
   "m.homeserver": {
       "base_url": "https://fedoraproject.ems.host"
   },
   "m.identity_server": {
       "base_url": "https://vector.im"
   },
   "org.matrix.msc3575.proxy": {
       "url": "https://fedoraproject.ems.host"
   }
}

You might want to try setting your profile to have an explicit homeserver and see if that fixes it:

[profiles.PROFILENAME]
user_id = "@whatever:fedoraproject.org"
url = "https://fedoraproject.ems.host"
ahs3 commented 3 months ago

On 30 Aug 2024 09:23, Ulyssa wrote:

It looks like there may be something odd going on with which server it's trying to connect to. I can see that it's getting back 404 responses from chat.fedoraproject.org

[snip ...]

But it looks like that's not the right Matrix homeserver URL:

% curl https://fedoraproject.org/.well-known/matrix/client
{  
   "m.homeserver": {
       "base_url": "https://fedoraproject.ems.host"
   },
   "m.identity_server": {
       "base_url": "https://vector.im"
   },
   "org.matrix.msc3575.proxy": {
       "url": "https://fedoraproject.ems.host"
   }
}

You might want to try setting your profile to have an explicit homeserver and see if that fixes it:

[profiles.PROFILENAME]
user_id = ***@***.***:fedoraproject.org"
url = "https://fedoraproject.ems.host"

Hrm. I was hoping I had just done something obviously silly. So, I dug a little more ...

My profile does have an explicit homeserver url:

url = "https://chat.fedoraproject.org"

This is the normal web page for element.

This allows me to use the Fedora SSO and verify my account. If I use the fedoraproject.ems.host url, I cannot seem to log in at all (JSON returns an M_UNRECOGNIZED errcode). So, I followed the CNAMEs for the original chat.fedoraproject.org and see fedora.element.io and some horrendous aws hostname -- and again M_UNRECOGNIZED.

So, it looks like the Fedora SSO handover from chat.fedoraproject.org to fedora.ems.host is not quite right, or their .well-known record should say chat.fedoraproject.org .... or something else. Homesever admin is not my strong suit, so I'll poke the Fedora infrastructure folks and see if they have any ideas.

In the meantime, just leaving iamb open works fine .... and going through SSO and verify again when needed, while messy, is doable.

-- Ciao, al

Al Stone E-mail: @.***

ahs3 commented 3 months ago

On 30 Aug 2024 11:28, Al Stone wrote:

On 30 Aug 2024 09:23, Ulyssa wrote:

It looks like there may be something odd going on with which server it's trying to connect to. I can see that it's getting back 404 responses from chat.fedoraproject.org

[snip ...]

But it looks like that's not the right Matrix homeserver URL:

% curl https://fedoraproject.org/.well-known/matrix/client
{  
   "m.homeserver": {
       "base_url": "https://fedoraproject.ems.host"
   },
   "m.identity_server": {
       "base_url": "https://vector.im"
   },
   "org.matrix.msc3575.proxy": {
       "url": "https://fedoraproject.ems.host"
   }
}

You might want to try setting your profile to have an explicit homeserver and see if that fixes it:

[profiles.PROFILENAME]
user_id = ***@***.***:fedoraproject.org"
url = "https://fedoraproject.ems.host"

Hrm. I was hoping I had just done something obviously silly. So, I dug a little more ...

My profile does have an explicit homeserver url:

url = "https://chat.fedoraproject.org"

This is the normal web page for element.

This allows me to use the Fedora SSO and verify my account. If I use the fedoraproject.ems.host url, I cannot seem to log in at all (JSON returns an M_UNRECOGNIZED errcode). So, I followed the CNAMEs for the original chat.fedoraproject.org and see fedora.element.io and some horrendous aws hostname -- and again M_UNRECOGNIZED.

So, it looks like the Fedora SSO handover from chat.fedoraproject.org to fedora.ems.host is not quite right, or their .well-known record should say chat.fedoraproject.org .... or something else. Homesever admin is not my strong suit, so I'll poke the Fedora infrastructure folks and see if they have any ideas.

In the meantime, just leaving iamb open works fine .... and going through SSO and verify again when needed, while messy, is doable.

So here's where I demonstrate my lack of understanding of matrix protocols :/ ....

My homeserver is https://fedora.ems.host (chat.fedoraproject.org is just the element client). As you noted, the .well-known record agrees. However, to login I use @ahs3:fedora.im, but the .well-known says the identity manager is vector.im. Is this a problem?

If I use fedora.ems.host and fedora.im, I can use their SSO just fine but cannot quit iamb and restart it later without removing the iamb cache and local storage, then going through the SSO/verify steps again. I don't use vector.im so that precludes me logging in. I am very puzzled. Do I just need to register an account at matrix.org that does use vector.im? Or perhaps just two different profiles in iamb? I suspect the latter at this point.

-- Ciao, al

Al Stone E-mail: @.***

ahs3 commented 2 months ago

On 01 Sep 2024 14:16, Al Stone wrote:

On 30 Aug 2024 11:28, Al Stone wrote:

On 30 Aug 2024 09:23, Ulyssa wrote:

It looks like there may be something odd going on with which server it's trying to connect to. I can see that it's getting back 404 responses from chat.fedoraproject.org

[snip ...]

But it looks like that's not the right Matrix homeserver URL:

% curl https://fedoraproject.org/.well-known/matrix/client
{  
   "m.homeserver": {
       "base_url": "https://fedoraproject.ems.host"
   },
   "m.identity_server": {
       "base_url": "https://vector.im"
   },
   "org.matrix.msc3575.proxy": {
       "url": "https://fedoraproject.ems.host"
   }
}

You might want to try setting your profile to have an explicit homeserver and see if that fixes it:

[profiles.PROFILENAME]
user_id = ***@***.***:fedoraproject.org"
url = "https://fedoraproject.ems.host"

Hrm. I was hoping I had just done something obviously silly. So, I dug a little more ... [snip ...]

Yet another experiment:

1) start up iamb with these settings:

[profiles.ahs3] url = "https://chat.fedoraproject.org" user_id = @.***:fedora.im"

Log in, run through verification, even catch up on discussions.

2) :quit iamb

3) change the config to:

[profiles.ahs3] url = "https://fedora.ems.host" user_id = @.***:fedora.im"

4) and iamb reconnected and sync'd just fine this time, without having to log in and reverify ...

I have not updated iamb. I have to log in and reverify if I do not take step (3) above. If I start with the config in step (3), iamb does not reconnect, and I have to remove the .local and .cache data to log in again. The .well-known is still the same:

$ curl https://fedoraproject.org/.well-known/matrix/client { "m.homeserver": { "base_url": "https://fedoraproject.ems.host" }, "m.identity_server": { "base_url": "https://vector.im" }, "org.matrix.msc3575.proxy": { "url": "https://fedoraproject.ems.host" } }

I have no idea if this adds any useful info -- just trying to grok what's happening really .....

-- Ciao, al

Al Stone E-mail: @.***

bombermuecke commented 1 month ago

I've had the same error message while trying to login to my matrix account at utwente.io. For me, the following solved it: usually, they (utwente) automatically redirect the server url from https://utwente.io to the actual address https://matrix.utwente.io. But it seems that this automatism does not work with iamb. After I changed the url in the iamb configfile to https://matrix.utwente.io, the login worked without issues. Maybe there is a similar issue with your matrix server.