Hello,
We are trying to create a simple console application in .Net(Windows machine) which connects couchbase lite → sync-gateway → couchbase server (hosted in a remote machine).
We followed the steps mentioned in the support doc(https://docs.couchbase.com/couchbase-lite/2.7/csharp.html), but the data is not pulled from the server to the lite.
here is the configuration used for sync_gateway -
{
“log”: [““],
“databases”: {
“testdb”: {
“server”: “http://167.87.210.35:8091”,
“bucket”: “Test”,
“username”: “System”,
“password”: “welcome”,
“enable_shared_bucket_access”: true,
“import_docs”: true,
“num_index_replicas”: 0,
“users”: {
“GUEST”: { “disabled”: false, “admin_channels”: [””] }
},
“sync”:function (doc, oldDoc) { if (doc.sdk) { channel(doc.sdk); } }
}
}
}
and here is the sample console application we have created -
using Couchbase.Lite;
using Couchbase.Lite.Query;
using Couchbase.Lite.Sync;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace CouchBase_sample
{
class Program
{
static void Main(string argss){ // Get the database (and create it if it doesn't exist) var database = new Database("testdb"); // Create replicator to push and pull changes to and from the cloud var targetEndpoint = new URLEndpoint(new Uri("ws://localhost:4984/testdb")); var replConfig = new ReplicatorConfiguration(database, targetEndpoint); // Add authentication replConfig.Authenticator = new BasicAuthenticator("System", "welcome"); // Create replicator (make sure to add an instance or static variable // named _Replicator) Replicator _Replicator = new Replicator(replConfig); _Replicator.AddChangeListener((sender, args) => { if (args.Status.Error != null) { Console.WriteLine($"Error :: {args.Status.Error}"); } }); _Replicator.Start(); // Later, stop and dispose the replicator *before* closing/disposing the database using (var query = QueryBuilder.Select(SelectResult.All()) .From(DataSource.Database(database))) { // Run the query Console.WriteLine($"Query :: {query.ToString()}"); var result = query.Execute(); Console.WriteLine($"Result :: {result.Count()}"); } } }
}
Is there any other doc/video for the same and is there any existing sample code/application.
Please find the screenshot which shows the error we get.
NOTE: sorry for previous screenshot. It was wrong one. I have provided correct screenshot for the error we are getting when we run the sample console application