Skip to content

[Feature Request] A new option or function to stay offline when disconnected during specific situations #128

@vrtmrz

Description

@vrtmrz

Hello! Nice to see you all again!
And, (possibly again but) let me introduce myself. We are creating the plug-in Self-hosted LiveSync which synchronises Obsidian Vaults between several devices, using a peer-to-peer connection.
Of course, trystero is tremendously fantastic for making this possible more securely. Thank you for your great work!

However, there is a minor issue. It is trivial and does not affect the core synchronisation, which works perfectly. And I hope we can find a solution.

If we disconnect the sockets, or are disconnected from the network, reconnection is always attempted after a timeout in the current implementation. In web apps, this is desirable behaviour that makes things simple and efficient. Also, they will be disconnected upon page-reload or navigation.

On the other hand, Electron Apps, and mobile apps always maintain the connection even when it is not actively being used. This is probably the same for PWAs. In this case, especially in mobile, the device may not be able to sleep properly, or may not be able to resume after sleeping. It also consumes a small amount of extra data.

Therefore, I would like to propose an option to temporarily disable automatic reconnection.

I think it seems simplest to really pause/resume the reconnection rather than initialise and recreate the client. I have implemented it as follows, and it seems to be working as expected.

https://github.com/vrtmrz/trystero/blob/942a973f1e7eedc5b3151452b790e2196bea4fa7/src/utils.js#L76-L115
https://github.com/vrtmrz/trystero/blob/942a973f1e7eedc5b3151452b790e2196bea4fa7/src/utils.js#L123-L128

May I ask what you think? If you think this is a good idea, please consider this feature.
And, if you are happy with my implementation, I would also be glad to create a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions