SaltechSystems / couchbase_lite

Flutter plugin for the Community edition of Couchbase Lite. Couchbase Lite is an embedded lightweight, document-oriented (NoSQL), syncable database engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Channels not working when I connect to CB the first time

josefwilhelm opened this issue · comments

Describe the bug

When I fetch data for the first time after app install I can't get data if I use the new 'channel' config. You can see my config code here. The line that is commented out is the problem. If I kill the app and restart, everything works fine. I test this on multiple Android phones

'final config =
ReplicatorConfiguration(database, 'wss://$host/fieldforce$client');
config.replicatorType = ReplicatorType.pushAndPull;
config.continuous = true;
// config.channels = [store.state.appSettingsState.username];
config.authenticator = SessionAuthenticator(token);
_replicator = Replicator(config);'

This is one of my queries

var query = QueryBuilder.select([ SelectResult.all(), ]).from(DATABASE_NAME).where( Expression.property('type').equalTo(Expression.string('job')), );

Maybe because of your query? I would look for connection logs on the phone. My code works well for months, even with new installs, might as well give it a try.

Connector:

      ReplicatorConfiguration config = ReplicatorConfiguration(
          database, "wss://$host/$sgw");
      config.replicatorType = ReplicatorType.pushAndPull;
      config.continuous = true;
      config.channels = ["channel1", "channel2"];
      config.authenticator = BasicAuthenticator(username, password);
      replicator = Replicator(config);

Query:

    final Query query = QueryBuilder.select([
      SelectResult.expression(Meta.id.from(typeUserState)).as("id"),
      SelectResult.expression(Expression.all().from(typeUserState)),
    ])
        .from(dbName, as: typeUserState)
        .where(Expression.property("type")
            .from(typeUserState)
            .equalTo(Expression.string(typeUserState))
            .and(Expression.property("userUUID").from(typeUserState).equalTo(Expression.string(userUUID))))