Unable to reconnect to Gladys Plus after internet outage

In the meantime, I think I’ve identified the bug.

In Gladys Assistant 4.56, I introduced a new authentication logic on the WebSockets, allowing a faster connection: ideal for instant access to the dashboard on mobile.

The problem? If the instance loses the connection, it tries to reconnect with the same access_token used during the first connection. Except that this access_token has expired in the meantime and is not renewed. I’m using a new logic present in the socket.io library and I didn’t understand its behavior on disconnection.

Result: the Gladys Plus backend rejects the connection (expired JWT), and the instance enters an infinite reconnection loop.

It’s a good lesson, and a few avenues for improvement:

  1. Renew the access_token in case of connection loss to resume with a valid token.

  2. Add a delay before reconnecting, to avoid overloading the server in case of an infinite loop.

  3. Strengthen unit tests to better cover connection loss scenarios and prevent this bug from recurring.

Sorry for the inconvenience!

I’ll keep you informed as soon as version 4.56.1 is available :slight_smile:

3 Likes