Skip to content
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

replicateWithWebsocketServer prints endless connection errors although state is canceled #5900

Open
koh-osug opened this issue Apr 13, 2024 · 4 comments

Comments

@koh-osug
Copy link

In my error logic I want to stop the replication and use the cancel function of the RxReplicationState. The implementation still continuously prints:

WAS CLIENT GOT ERROR: connect ECONNREFUSED 127.0.0.1:1235

Although the server on the other end is terminated and will also never be started again in my case this error is printed forever.

How to stop the replication attempts and close the web socket behind?

This is my code to connect a client to the replication server:

 const serverState = await replicateWithWebsocketServer({
        collection: collection,
        url: `ws://${ipAddress}:${port}/socket`,
        waitForLeadership: false
    });
    serverState.error$.subscribe(async (err) => {
        logger.error({
            collection: collection.name,
            ipAddress: ipAddress,
            port: port,
            err: err.message
        }, "error in replication server connection");
        await serverState.cancel();
    })

The cancel function should also disconnect from the server or the RxReplicationState should allow to close the web socket.

@koh-osug
Copy link
Author

I see that in 15.7.0 RxReplicationState.remove. For my purposes a RxReplicationState.stop to close the web sockets would be most likely the solution. What is the idea behind to leave the web socket open?

@koh-osug
Copy link
Author

My fix is to make the websocketClient part of the options similar to what can already be done for the replication server:

master...koh-osug:rxdb:master#diff-8395abd4c40a2116444ebd5daf4c5f307401693b498faa62513decf879ee2c9f

Now I can close the socket manually and the replication client can be terminated.

@pubkey
Copy link
Owner

pubkey commented Apr 17, 2024

The socket should stop retrying the connection when there is no more active replication state. Please make a PR.

Copy link

stale bot commented Apr 29, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. If you still have a problem, make a PR with a test case or to prove that you have tried to fix the problem. Notice that only bugs in the rxdb premium plugins are ensured to be fixed by the maintainer. Everything else is expected to be fixed by the community, likely you must fix it by yourself.

@stale stale bot added the stale label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants