appy-one / acebase-client

Client to connect to remote AceBase NoSQL database server
MIT License
21 stars 8 forks source link

There is a problem with replication #13

Closed topapp2030 closed 3 years ago

topapp2030 commented 3 years ago

Hello! There is a problem with replication The situation in which it occurs, if the port is closed in the server Data has been sent from the client Then a minute later, the data will disappear from the client device Even if the port is opened after that, the data will not arrive I hope my explanation is clear or tell me to explain to you in a video

This is the server code :

const { AceBaseServer } = require('acebase-server');
const dbname = 'serverdb';
const settings = {
    host: '192.168.1.108',
    port: 5757,
    authentication: {
        enabled: true,
        allowUserSignup: true,
        defaultAccessRule: 'auth',
        defaultAdminPassword: '123456'
    }
}
const server = new AceBaseServer(dbname, settings);
server.ready(() => {
  console.log('Server running 3333333'); 
})

This is the client code:

const { AceBase } = require('acebase');
const { AceBaseClient } = require('acebase-client');
const localdb = AceBase.WithIndexedDB('localdb');  // browser
const db = new AceBaseClient({ cache: { db: localdb },host: '192.168.1.108', port: 5757, dbname: 'serverdb', https: false });
db.auth.signIn('admin', '123456')

function push(){
  db.ref('game/config').push({name: new Date() ,test : 111111});
}
topapp2030 commented 3 years ago

@appy-one I think the problem is with the sending order It should check if the server port is open Because here the error occurs and deletes the data from the client

appy-one commented 3 years ago

It's true that sync will remove pending mutations upon failure (I will change this behaviour in a future version), but sync only runs after it has connected to the server (and signed in) so that can't be the issue.

I don't see any data retrieval code in your samples so it is kind of hard to see what is going wrong. I do see you are not waiting for the signIn to complete so that might be part of your issue - your server config requires authentication so anything you do before signing in will fail

appy-one commented 3 years ago

Let me know if this is still an issue, I will close it otherwise