rxdb
rxdb copied to clipboard
replicateWithWebsocketServer prints endless connection errors although state is canceled
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.
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?
My fix is to make the websocketClient
part of the options similar to what can already be done for the replication server:
https://github.com/pubkey/rxdb/compare/master...koh-osug:rxdb:master#diff-8395abd4c40a2116444ebd5daf4c5f307401693b498faa62513decf879ee2c9f
Now I can close the socket manually and the replication client can be terminated.
The socket should stop retrying the connection when there is no more active replication state. Please make a PR.
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.
Issues are autoclosed after some time. If you still have a problem, make a PR with a test case or to prove that you have tried to fix the problem.