Got LiteCore error: Not Found (6/404)

.net

#1

We have just upgraded our SyncGatewaty to 2.1. So now I’m refactoring our client code to use CouchbaseLite 2.1. When I try to replicate I get “Got LiteCore error: Not Found (6/404)” error. I origonly got the error when connecte to our Dev Server, and then installed a loacal “clean” copy on my laptop and I get the same error when trying to conect to it too.

log…

INFO) Couchbase 2019-01-10T10:56:47.8503147-07:00 (Startup) [1] CouchbaseLite/2.1.2 (.NET; Microsoft Windows 10.0.17763 ) Build/13 LiteCore/ (15) Commit/9aebf28 WARNING) LiteCore 2019-01-10T10:56:48.1943139-07:00 {C4SocketImpl#1}==> class litecore::repl::C4SocketImpl ws://localhost.com:443//_blipsync WARNING) LiteCore 2019-01-10T10:56:48.1943139-07:00 {C4SocketImpl#1} Unexpected or unclean socket disconnect! (reason=WebSocket status, code=404) ERROR) Sync 2019-01-10T10:56:48.1993137-07:00 {Repl#2}==> class litecore::repl::Replicator c:\temp\content_meta_data.cblite2\ ->ws://localhost:443//_blipsync ERROR) Sync 2019-01-10T10:56:48.1993137-07:00 {Repl#2} Got LiteCore error: Not Found (6/404)

code:

using System;
using System.IO;
using Couchbase.Lite;
using Couchbase.Lite.Support;
using Couchbase.Lite.Sync;
using NLog;

namespace ReplicatorExample
{
    public class DatabaseManager
    {
        private static readonly Logger _log = LogManager.GetCurrentClassLogger();
        public const string BUCKET_CONTENT_META_DATA = "content_meta_data";
        private static DatabaseManager _instance;

        public static DatabaseManager GetInstance()
        {
            NetDesktop.Activate();
            NetDesktop.EnableTextLogging("logs");
            
            return _instance ?? (_instance = new DatabaseManager());
        }

        public void InitializeBuckets()
        {
            try
            {
                var defaultAuthenticator = GetDefaultAuthenticator();

                var dirInfo = new DirectoryInfo($"c:\\temp\\{BUCKET_CONTENT_META_DATA}");
                if (!dirInfo.Parent.Exists)
                {
                    dirInfo.Parent.Create();
                }

                var database = new Database(dirInfo.FullName);

                // Create replicator to push and pull changes to and from the cloud
               var targetEndpoint = new URLEndpoint(new Uri("ws://localhost:4985"));
               var replConfig = new ReplicatorConfiguration(database, targetEndpoint)
                {
                    Authenticator = defaultAuthenticator,
                    Continuous = true,
                    //Channels = new List<string>
                    //{
                    //    "approved",
                    //    
                    //}
                };
                var replicator = new Replicator(replConfig);
                replicator.AddChangeListener((sender, args) =>
                {
                    if (args.Status.Error != null)
                    {
                        _log.Error($"{args.Status.Error}");
                    }
                    else
                    {
                        _log.Debug(args.Status);
                    }
                });
                replicator.Start();
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
        }

        private Authenticator GetDefaultAuthenticator()
        {
            return new BasicAuthenticator("BigD","123456");
        }

      
    }
}

#2

The URL you are using in your replication (ws://localhost:4985) is suspicious to me. Please double check it because it is missing a database name.


#3

@davebrighton Jim’s observation seems like the likely culprit. some additional points to note

  • while this shouldn’t be the cause , you should not be connecting over the admin port (4985) to the Sync Gateway. Please use 4984 instead
  • Also, not sure why you are seeing 443 ( ws://localhost:443) . Thats the SSL/TLS port . Double check your setup. if you have SSL/TLS configured , then you should use wss endpoint

#4

Yes… sorry I edited the real url for the post as I do not want publish to the world the real endpoint. The real end point is “wss://syncgw1-qa.xxxxxx.com:4984”
In the post I had port 4985, but I see the same error when using the real end point (using port 4984). My android college is doing the same thing that I’m trying to do using Couchbase Lite 2.x for android and and his code is working.

Also I found out that our SyncGateWay is the enterprise version so I’m now using Couchbase lite Enterprise version. Still getting the error, however as a side point, after moving to the Enterprise version the log file is kinda messed up now. see the post below for an example.

I can provide you the real end point if you want but I don’t want to post it on the forum.


#5

The 443 was I typo. I changed the address in the post as I did not want to publish our real endpoint. The real end point looks something like this “wss://syncgw1-qa.xxxxxx.com:4984” .


#6

As side note: Here is a log file generated by the Couchbase Lite Enterprise edition: note the garbled char. In the standard version of Coucbase Lite the log file look fine.

ϲ«e•Êâá”å: ---- %s ---- :Generated by LiteCore EE build number 15 from commit 2.1.2Â~Couchbase %.*s v(Startup) [1] CouchbaseLite/2.1.2 (.NET; Microsoft Windows 10.0.17763 ) Build/13 LiteCore/ (15) Commit/9c85d49-9aebf28þöActor Starting Scheduler<%p> with %u threads xÎ
÷ÆWS class litecore::repl::C4SocketImpl wss://syncgw1-qa.in2lxxxxx.com:4984//_blipsync aUnexpected or unclean socket disconnect! (reason=%-s, code=%d) WebSocket status ”Û Sync class litecore::repl::Replicator I:\in2l-engage\qa\data\content_meta_data.cblite2\ ->wss://syncgw1-qa.in2lxxxxxx.com:4984//_blipsync
Got LiteCore error: %.*s (%d/%d) Not Found ”


#7

Your URL is missing the database name, as @borrrden pointed out yesterday. It should look like wss://syncgw1-qa.xxxxxx.com:4984/databasename. That’s the reason for the log errors you posted.


#8

Thank… I missed that when reading the documentation and the emails.


#9

I was surprised we didn’t immediately return an error from Replicator.start, so I looked into the code path. I’ve just added such a check, which will make this mistake a lot easier to discover and fix.