Oracle, Couchbase server 5.0, Sync gateway 1.5 and Couchebase Lite 2.0?

Hi,

I’m starting a project where I will need to sync some mobile devices with a central application which use oracle as database.

I want to use a couchbase server 5.0, and to make a link with oracle, using either Talend or a custom .Net application with the couchbase SDK, which will sync the documents into my bucket.

To maintain the link between the couchbase server and the local database on the mobile devices, I want to use Sync gateway 1.5.

As I am using Xamarin.forms, c#, .Net for my mobile project, I have to use Couchbase 2.0 (developer branch) to be compatible with the UWM part.

My question is :
If I’m creating, or updating a document on couchebase server, thru Talend or my custom .Net programm, will it sync automatically truw sycn gateway and be present and up to date into my local database ?

Same question in the inverted way, if I’m creating or updating a document on my mobile application, will it sync automatically thru sync gateway to be finaly up to date in my oracle database ?

Regards

Steeve

Yes with sync gateway 1.5 and Couchbase server 5.0 direct updates in couch-base also travels to mobile. In older versions one has to use sync gateway to change document data.

Do let me know if you get success with Talend.

Hi,

Thank you for this confirmation.

No success with talend, sadly, the only version I found is a Talend for big data which worked with the version 2.0 of couchbase server, and we wasn’t abble to connect to oracle 10.

We will go with a custom .Net program, but I have some troubles to connect with the bucket.

It’s not so easy to start with couchbase !!

Regards,

Steeve

May be you are finding it difficult right now. But it eliminates a lot of things which we have to do for local db in mobile. Do let me know what difficulties you are facing ?

Hi,

Thank you.

I created a new console windows app to read some infos from my oracle database, and I’m trying to connect with my Bucket to store this infos.

Here is my c# Code :

IList lstPgr = TProgramme.SelectAllConditions(new TProgramme { SocCode = "1", Etat = 1 });
        Console.WriteLine($"{lstPgr.Count} programmes à la vente");

        ClientConfiguration clientConfig = new ClientConfiguration
        {
            Servers = new List<Uri>
            {
                new Uri("http://192.168.53.100:8091/pools")
            },
            
            BucketConfigs = new Dictionary<string,BucketConfiguration>
            {
                { "mobilotis", new BucketConfiguration
                    {
                        BucketName = "mobilotis",
                        Username = "Administrator",
                        Password = "*****"
                    }
                }
            }
        };

        Console.WriteLine("Open cluster");

        Cluster cluster = new Cluster(clientConfig);

        IBucket bucket = null;
        try
        {
            Console.WriteLine("Bucket Opening ...");

            bucket = cluster.OpenBucket();

            Console.WriteLine("Adding programs");
            foreach (TProgramme programme in lstPgr)
            {
                Console.WriteLine($"Programme {programme.Localite} - {programme.Libelle}, Num={programme.Num} ");
                Document<TProgramme> document = new Document<TProgramme>();
                document.Content = programme;

                bucket.Insert(document);
            }
           
        }
        catch(Exception e)
        {
            Console.WriteLine(e.Message);
            Console.WriteLine(e.StackTrace);
            Console.WriteLine(e.InnerException.Message);
            Console.WriteLine(e.InnerException.StackTrace);
        }
        finally
        {
            if (bucket != null)
                cluster.CloseBucket(bucket);
        }           

I have an exception when I’m trying to open the Bucket :

Open cluster

Bucket Opening …
Could not bootstrap - check inner exceptions for details.
à Couchbase.Core.ClusterController.CreateBucket(String bucketName, String password, IAuthenticator authenticator)
à Couchbase.Core.ClusterController.CreateBucket(String bucketName, IAuthenticator authenticator)
à Couchbase.Cluster.OpenBucket()
à MobilotisConnect.Program.Main(String[] args) dans C:\Projets\ElotisProd\src\MobilotisConnect\Program.cs:ligne 55
Une ou plusieurs erreurs se sont produites.
à Couchbase.Configuration.Server.Providers.CarrierPublication.CarrierPublicationProvider.GetConfig(String bucketName, String username, String password)
à Couchbase.Core.ClusterController.CreateBucket(String bucketName, String password, IAuthenticator authenticator)

Line 55 is :
bucket = cluster.OpenBucket();

I think I’m following the docs, but I’m probably missing something…

Regards,

Steeve

@jmorris Please help here.

@steeve.descarpentrie -

I think the problem is that you are not explicitly opening the bucket by name so the SDK is trying to open the default bucket. Try this:

var bucket = cluster.OpenBucket("mobilotis");

LMK how that works.

-Jeff

If you setup enable_shared_bucket_access as described here: https://developer.couchbase.com/documentation/mobile/current/whatsnew.html

Any changes that are made in Couchbase Server via the SDK will be mirrored in Sync Gateway, and vice-versa.

Hi,

I tried with the change you suggested, but I’hv the same result.
var bucket = cluster.OpenBucket("mobilotis");
Any other idea ?

Regards,

Steeve

@steeve.descarpentrie -

Ok, at this point we would need to see the full stacktrace and even better client logs. The AggregateException that is thrown should have an couple of inner exception collections which contain the actual exception that was thrown which was consolidated by the AggregateException.

If the logs are sensitive material, you can send them to me directly: jeffry dot morris at couchbase.com or send me a DM.

-Jeff

Hi Jeff,

Good job, you made the point, There was an inner exception, about Authentification faild with user mobilotis.

If you look back at my post, my bucketConfigs dictionnary include an entry with an Username = Administrator, and not mobilotis.

For a test purpose, I added a new user mobilotis on my server, and I had no trouble to connect the bucket and to add documents.
That’s half good, because I have at least a working solution, but why do I have to create a user with the name of my bucket ? I’m using couchbase server 5.0, couchbase net client 2.5.2 (thru NuGet).

Regards,

Steeve

That is a bit confusing for me too. There is a case where the username is the same as the bucket name - this is the “upgrade” scenario where you have a pre-4.0 cluster, which doesn’t understand what a user is (no RBAC), and you upgrade the cluster to 5.0 or greater. In this case a user will automatically be created that uses the bucket name as the username so that upgrading is seamless on the fly. Perhaps that is what you are seeing?

-Jeff

Couchbase team needs to update this https://developer.couchbase.com/documentation/mobile/1.5/installation/sync-gateway/index.html because it says “Note: Do not add, modify or remove data in the bucket using Couchbase Server SDKs or the Admin Console, or you will confuse Sync Gateway. To modify documents, we recommend you use the Sync Gateway’s REST API.” I almost choose another solution because of this lol.

1 Like

Good catch! I have filed a bug with the Docs team to fix it. Glad you investigated it before you made your decision :slight_smile: