Skip to content

Error on replicator when adding set of collections #602

@jhay06

Description

@jhay06

Can't make it work when database and collections was set in replicatorCOnfig

"Invalid config: Both database and collections are set at same time"

i test from the instruction and i got that issue

// Purpose -- illustrate a simple change listener
static void simpleChangeListener(void* context,
CBLReplicator* repl,
const CBLReplicatorStatus* status)
{
if(status->error.code != 0) {
printf("Error %d / %d\n",
status->error.domain,
status->error.code);
}
}
// Purpose -- Show configuration , initialization and running of a replicator

// NOTE: No error handling, for brevity (see getting started)
// Note: Android emulator needs to use 10.0.2.2 for localhost (10.0.3.2 for GenyMotion)

CBLError err{};
FLString url = FLSTR("ws://localhost:4984/db");
CBLEndpoint* target = CBLEndpoint_CreateWithURL(url, &err); 

CBLReplicationCollection collectionConfig;
memset(&collectionConfig, 0, sizeof(CBLReplicationCollection));
collectionConfig.collection = collection;

CBLReplicatorConfiguration replConfig;
memset(&replConfig, 0, sizeof(CBLReplicatorConfiguration));
replConfig.collectionCount = 1;
replConfig.collections = &collectionConfig;
replConfig.endpoint = target; 

// Set replication direction and mode
replConfig.replicatorType = kCBLReplicatorTypePull; 
replConfig.continuous = true;

// Optionally, set auto-purge behavior (here we override default)
replConfig.disableAutoPurge = true; 

// Optionally, configure Client Authentication
// Here we are using to Basic Authentication,
// Providing username and password credentials
CBLAuthenticator* basicAuth =
    CBLAuth_CreatePassword(FLSTR("username"),
                           FLSTR("passwd")); 
replConfig.authenticator = basicAuth;

// Optionally, configure how we handle conflicts (note that this is set
// per collection, and not on the overall replicator)
collectionConfig.conflictResolver = simpleConflictResolver_localWins; 

// Initialize replicator with created config
CBLReplicator* replicator =
    CBLReplicator_Create(&replConfig, &err); 

CBLEndpoint_Free(target);

// Optionally, add change listener
CBLListenerToken* token =
        CBLReplicator_AddChangeListener(replicator,
                                        simpleChangeListener,
                                        NULL); 

// Start replication
CBLReplicator_Start(replicator, false); 

removing the collectionConfig from replConfig works but only defaultCollection is being sync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions