The Problem:
Well the most obvious problem is that the sync is not working. When creating a new document via .NET, it is not pushed into the bucket. Also I put a document into the bucket via admin-console and it is not pulled (db.GetDocument returns null).
When I break in “onReplicationCompleted” the “replicationEvent” also contains a LastError: LastError = {LiteCore.LiteCoreException: LiteCoreException (400): Bad Request}
Also the console in which the sync-gateway runs doesn’t even show a connection-request. When I connect via browser (http://our.couchbase.server.ip:4985/simon-sync-db/_all_docs?include_docs=true) it shows the existing document correctly and in the console of the running sync-gateway I see the connection-request.
What I’ve tried
Using “walrus:” with a different bucket instead of the existing bucket on the cb-server
because the new 2.0 replication protocol only supports websocket/blip.
I also tried blip:// with the same result as ws://. blips / wss don’t work because of certificate errors. But I would assume it should work without encryption. (?)
It appears we get the same error. We have been trying to get sync online between Server 5.0.0(3217)+Gateway 1.5v477 and WinForms .NET 4.7 and .NET Standard 2.0. Running the replicator from CBL NuGet 2.0db016 from desktop using Replication protocol 2.0 and ws:// URI gives us a 400 error and nothing showing in the gateway console, the websocket just disconnects uncleanly. When we try to connect to the ws:// using plugin in Chrome it does connect and shows up on the server that a connection occurred. We also tried to connect with and without authentication.
Debug log output from CBL and program, and C# test code attached.
Without reading the logs (on my phone) it almost seems like sync gateway is not configured for the version 2 replicator. In the unsupported section I think there needs to be an entry called “replicator_2” whose value is true.
thanks for taking the time to answer!
I posted our sync-config above and it contains the unsupported replicator_2. It is placed inside the database-object as per documentation. I assume this is correct?
I would also assume avia_bdg also has this inside his sync-config.
To make sure, I’ll try and “port” the important parts from the iOS Demo to .NET. But from what I see at first glance in the code, the replication is the same as what we already tried in .NET and posted above in the OP :(.
Looking through the iOS-Demo implementation the only relevant part seems to be in startPushAndPullReplicationForCurrentUser
which is basically the identical code to what I posted in the OP (just in swift, obviously).
Adapting the above code to use the travel-sample database, correct user and channel (channel.{username}) – just like in the iOS demo – still results in the same behaviour with a 400 Bad Request error and nothing showing up in the sync-gateway-console.
Either I’m missing something very elementary or this is a bug in the .NET implementation.
I’ll open an issue on github. But if anyone has an idea or comment, please also post here :/.
That’s certainly disappointing. The actual logic that creates those messages is in the native library so it must be web sockets acting up. I haven’t seen that issue (or at least I don’t remember seeing it) so I will fire up the tests for sync gateway again and see what happens tomorrow. I’ll report further on the ticket.
For anyone interested, I opened the Github-Issue here:
I also in the meantime tried using Xamarin Shared Project and PCL, but both didn’t work either. I’m still not 100% certain, if it’s a bug or my own stupidity :/.
@borrrden : I saw on github, you made some efforts to port the todo-example into 2.0 UWP and .NET Standard. Is there any Version of that, that should currently work? (like the feature/2.0 branch?)