couchbase / couchbase-lite-net

A lightweight, document-oriented (NoSQL), syncable database engine for .NET
http://developer.couchbase.com/mobile/
Apache License 2.0
438 stars 126 forks source link

Couchbase lite 2.0, DB22, Xamarin c#, replicator exceptions #967

Closed SteeveQuadra closed 6 years ago

SteeveQuadra commented 6 years ago

Hi,

I finished to instal sync gateway 2.0 beta, and made all the changes in my Xamarin forms, c# solution to work with de db22 version of couchbase Lite. This issue is linked with the #945 that was closed thinking the db22 will correct the problem.

I’m using a sync gateway installed on my computer, windows 10 fall creator update, to be sure it’s no network trouble.

When I’m lauching my app for the first time, I’ve around 40000 doc to sync from my bucket. I added a log of the replicator exceptions I have that message :

LiteCoreException (1005): no status code received

I tried to restart the replicator, after some restart and the same exception, I’ve a crash of my app, and after that, the replicator exception message change to :

LiteCoreException (35): Invalid sequence ID in 'since': "39478:23249"

I’m so sad this db22 version did’t solve the replication problem I had since the db19, and db21 versions.

What can I do to solve this problems ?

Regards

Steeve

borrrden commented 6 years ago

The second one is a known issue, and the error message is actually coming from Sync Gateway (as evidenced by error code 35 which I know is not yet documented but it means "remote error" The definitions of these codes will come soon and I'm having a meeting today about just this).

As for the app crash, do you have any details about that like stack trace? Even in the presence of these failures the app should not crash so it probably means I've missed a chance to catch.

Either that or it could be #962 or #963

SteeveQuadra commented 6 years ago

Hi,

borrrden : As for the app crash, do you have any details about that like stack trace? I'm trying to have it, but it seems to be an Unmanaged win 32 exception in an async thread, I'm using the UWP part of my xamarin solution.

I don't know how to catch it.

Regards Steeve

SteeveQuadra commented 6 years ago

Hi,

I tested the Android project of my xamarin forms App, Here some log that could be useful :

00:48:34.834547| [BLIP]: {N8litecore4blip10ConnectionE#4} Closed with WebSocket status 1005: 
00:48:34.834816| [BLIP]: {N8litecore4blip6BLIPIOE#5} Notifying 1 incoming messages they're canceled
00:48:34.835134| [Sync] ERROR: {Repl#6}==> N8litecore4repl10ReplicatorE /data/user/0/fr.QuadraDiffusion.mobiLotis/files/mobilotis.cblite2/ ->ws:192.168.43.153:4984/mobilotis/_blipsync
00:48:34.835254| [Sync] ERROR: {Repl#6} Got LiteCore error: no status code received (7/1005)
00:48:34.840187| [BLIP]: {N8litecore4blip6BLIPIOE#5} ~BLIPIO: Sent 520837 bytes, rcvd 1708252. Max outbox depth was 1, avg 1.00Thread finished:  #582

Steeve

SteeveQuadra commented 6 years ago

I have the same 2 kinds of exceptions with the Android project.

LiteCoreException (1005): no status code received
LiteCoreException (35): Invalid sequence ID in 'since': "39478:23249"

But it's completely random. I even had a complete sync without trouble.

Steeve

SteeveQuadra commented 6 years ago

Hi,

I changed the cpu version from x86 to x64, cause I'm desparate and I don't know how to help. I had that exception :

        Message "The given key was not present in the dictionary."  string

   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Couchbase.Lite.Sync.WebSocketTransport.DoCompleteReceive(C4Socket* socket, UInt64 bytecount)
   at LiteCore.Interop.SocketFactory.SocketCompletedReceive(C4Socket* socket, UIntPtr byteCount)

Hope this will help.

Steeve

borrrden commented 6 years ago

Yes this is definitely the ticket I mentioned above then. It’s causing problems with replication...and unfortunately it’s not preventable from the user side. The change had nothing to do with it I think this problem just manifests in many different ways. Or it could still be separate problems.

rainerg2000 commented 6 years ago

@borrrden, when replication stops I am also seeing "LiteCoreException (1005): no status code received" in the Replicator ChangedListener, as @SteeveQuadra reported in the original Issue.

SteeveQuadra commented 6 years ago

Hi, I'm so happy not to be the only one, I begun to beleive I was mad , with this LiteCoreException (1005): no status code received !

Regards, Steeve

borrrden commented 6 years ago

I haven't seen that particular case yet, but I've been hammering away at other bugs dealing with replication (like the one linked above). You probably have stopped believing me at this point, but I am working quite a lot on it, and our testing framework has expanded to gain the ability to test live replication with sync gateway in new ways, and it is automated so the only way to go from here is up.

SteeveQuadra commented 6 years ago

I believe in you Jim, and I understand how complicated it is. And yes, I'd like to be able to use a working replication, because I've to deliver a version of my app for the end of this month. Be strong !

borrrden commented 6 years ago

@rainerg2000 @SteeveQuadra Are there any details you can give about the environment in which the 1005 happens? I haven't been able to reproduce this specific case yet.

SteeveQuadra commented 6 years ago

Hi Jim @borrrden,

That's so strange, I have always this exception. I'm using a sync Gateway 1.5 installed with a Docker, for db21 use, thru an open VPN network access. This case use a couchbase server 5.0 installed with docker too. I'm using a sync Gateway 1.5 installed on a Windows 10, for db21 use, thru standard network access, this case use a couchbase server 5.0 installed on an windows server 2008, on the local network.

And for the DB22, I installed Sync Gateway 2.0 beta on my windows 10 computer, up to date in windows fall creator, cause I didn"t wanted to have network trouble. I'm testing my app UWP on the same computer, and of course when I'm testing my app with my android tablet, it's thru the local wifi network. The bucket is on a couchbase server 5.0 on the same windows.

Here is my sync gateway config file :

{
    "databases":    
    {
        "mobilotis": 
        {
            "log": ["*"],
            "server": "http://localhost:8091",
            "bucket": "mobilotis",
            "username": "mobilotis",
            "password": "PASSWORD",
            "users": 
            {
                "commercial": 
                {
                    "disabled": false, 
                    "admin_channels": ["*"], 
                    "password":"PASSWORD", 
                    "name":"commercial"
                },
                "quadra": 
                {
                    "disabled": false, 
                    "admin_channels": ["*"], 
                    "password":"PASSWORD", 
                    "name":"quadra"
                }
            },
            "enable_shared_bucket_access": true,
            "import_docs": "continuous",
            "unsupported": {
                "replicator_2": true
              },
            "sync": `function (doc, oldDoc) {
                if (doc.sdk) {
                    channel(doc.sdk);
                }
            }`
        }
    }
}

I have send to you my app code in another post, now closed. Since i'm using couchbase, begun with the db19, I always had this exception.

Steeve

rainerg2000 commented 6 years ago

I saw "LiteCoreException (1005): no status code received" in a UWP app on Fall Creator's (1709). CB Lite DB022. With SG 1.5.1 on Oracle Linux Server 7.4. Since then I have learned that SG 2.0 Beta is required, and I have upgraded. Now I cannot reproduce "LiteCoreException (1005): no status code received" anymore.

borrrden commented 6 years ago

And for the DB22, I installed Sync Gateway 2.0 beta on my windows 10 computer

Can you disable the 1.5 sync gateway instances while you run this testing to ensure that it is not accidentally connecting to them @SteeveQuadra ? Otherwise, will the app you sent me as it is in the other ticket reproduce this issue if I run with DB022?

SteeveQuadra commented 6 years ago

I unstalled sync gateway 1.5 before installing sync gateway 2.0 beta on my computer, I din't wanted to risk to make a bad test.

My app would probaly reproduce the exception, but I sent it to you before the db22, so there are some change to do. I'll prepare today a light version of this app in db22 version and I will post it on github.

Steeve

SteeveQuadra commented 6 years ago

Hi Jim @borrrden,

I did push a solution xamarin UWP and android here : Cbl2Db22RepTest

I did commit a 7z with my bucket backup, and the config file for sync gateway.

Hope you will find what you're looking for.

Regards

Steeve

SteeveQuadra commented 6 years ago

For information, you will need to click on the "Replicator" button to be able to enter the user, password and location of the sync Gateway server. About the location, do not include http and ws, They will by add by the connector.

when you will click on the "Infos" button, you will fin a count by type of document. I have this count in the bucket :

[
  {
    "$1": 1,
    "table": "reservation"
  },
  {
    "$1": 38879,
    "table": "commune"
  },
  {
    "$1": 247,
    "table": "lot"
  },
  {
    "$1": 22,
    "table": "programme"
  },
  {
    "$1": 3,
    "table": "pays"
  },
  {
    "$1": 2,
    "table": "futuracquereur"
  },
  {
    "$1": 7,
    "table": "civilite"
  },
  {
    "$1": 10,
    "table": "typefinancement"
  },
  {
    "$1": 5,
    "table": "situationfamille"
  }
]

Steeve

borrrden commented 6 years ago

Unfortunately I am unable to restore the bucket data this time for some reason...

SteeveQuadra commented 6 years ago

Hi,

Will it help if I give you access to a sync gateway version 2.0 beta, plugged with my bucket, to test with my app ?

Steeve

borrrden commented 6 years ago

If that is repeatable then yes that would be very helpful. I was going to bother some people in the company to help me use cbrestore properly (you are probably better at it than me since I rarely interact directly with these kinds of server tools) also.

borrrden commented 6 years ago

I closed this to track the commit that I think fixed this, but since it is intermittent I can't be completely sure. @raghusarangapani If you see this again (#977 is the same I'm almost 100% sure) then reopen this ticket.

SteeveQuadra commented 6 years ago

Hi Jim @borrrden,

It took me some time, but I installed a sync gateway 2.0 beta 1 server on an Windows 10 (temporary available for 3 weeks) that you can Access from the web. In link with a new couchbase 5.1.0 server, and my bucket with around 40000 documents.

I added (commit) a file TestServerAccess.txt.gpg in my solution Cbl2Db22RepTest crypted with your GPG key, in which you will find the user, password and url to use in my app.

So you can start my app, I had the exceptions without problem.

Hope this will help.

Steeve

borrrden commented 6 years ago

@SteeveQuadra In the meantime I'm pretty sure I have found and corrected this issue. I will try running your project to see if it matches up with what I was seeing though.