question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid access token leads to "Connectivity to the server has been lost" with no way to gracefully recover - need to manually logout and re-login

See original GitHub issue

Steps to reproduce

  1. Lost connection to server, probably because of a internet connection issue from Server side.
  2. Checked that the Server is back up.
  3. Tried to send messages etc., but Client still insists that the Server is not available.
  4. Searched in the server logs, found error SynapseError: 401 - Invalid Authorization header.
  5. Searched the internet and found this: https://github.com/vector-im/element-web/issues/14529#issuecomment-879849922
  6. After Logout and Re-login everything was working normal, just as suggested by the user.

Outcome

What did you expect?

Client should be able to reconnect to a server by itself without a logout being necessary. Client should at least show a useful error message.

What happened instead?

Client insisted that a connection is not possible without any explanation.

Operating system

Manjaro Linux

Application version

Element v1.11.2

By the way, this problem also occurs with the Android App.

How did you install the app?

Manjaro Repos

Homeserver

Synapse 1.64.0

Will you send logs?

No

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
MadLittleModscommented, Aug 11, 2022

It sounds like your access token is no longer valid so you can’t authenticate and communicate with the homeserver anymore. Your token could have been invalidated in a number of different ways. Is there anything special about your homeserver setup (SAML, SSO, CAS)?


The client should handle this situation automatically either by refreshing the token, or by showing login form again (worse, but still less frustrating than just permanent disconnect).

@skobkin, https://github.com/vector-im/element-web/issues/14529#issuecomment-879849922

As the other person suggested, when the client sees a 401 - Invalid Authorization header response from the homeserver, it should ask you to sign in again. Maybe this means completely signing you out but it seems a bit more friendly if we just update the RoomStatusBar to take this situation into account and explain that you need to sign in again since your token is no longer valid.

It seems like soft-logout is a concept in the app so we could probably adapt some of that. Or maybe we’re just missing a case to trigger that.

If it’s possible use the refresh token to get a new access token, we should also be doing that. I see code for refreshToken but I don’t see any usage of this. So this is also something we might need to look at and improve.

1reaction
toby63commented, Aug 12, 2022

@toby63 From another device, is it possible that you cleaned up your devices/sessions yourself? Settings -> Security & Privacy -> Where you’re signed in -> and signed out some devices

No. This problem occured with multiple accounts, also with other users on my server.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Are Refresh Tokens and How to Use Them Securely
The Auth0 Authorization Server recognizes that someone is reusing Refresh Token 1 and immediately invalidates the refresh token family, ...
Read more >
Invalidating JSON Web Tokens - Stack Overflow
A common approach for invalidating tokens when a user changes their password is to sign the token with a hash of their password....
Read more >
Fix list for IBM WebSphere Application Server V8.5
The following is a complete listing of fixes for V8.5 with the most recent fix at the top. Content. Back to all versions ......
Read more >
Fixes, Limitations, and Known Issues - ForgeRock Backstage
OPENAM-17673: Nodes within a Page node do not have access to secure state ... OPENAM-17349: OIDC Refresh token - Ops token is deleted...
Read more >
Meta for Developers | How-To: Handle expired access tokens
One of the most frequently asked for “How-To” requests from developers is how to handle invalid access tokens. Access tokens for users can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found