Sync Issue On Android and IOS

I have setup a couchbase server on AWS Linux Machine with sync Gateway, allow all traffic on server and also using public DNS and public IP. I create channels and roles for user successfully. Everything is fine in server side.
But, at the mobile end issue is Slow Syncing
Some time I get real time sync, some times sync after 12 hour and some time document will never sync without any reason.

Every time on the server side document is always present on my _changes
Like: http://user:password@server:adminport/db/_changes
But device puller will not pull the document, when application is in stack, not in stack, try too many ways exclude filter pull and after few hours suddenly document sync to device without any reason, I have restart sync gateway, couchbase server, Linux Machine too many time, I am not able to find the exact reason of slow syncing, please help us to sort out this issue…

Issue is persist in Android and IOS both

I have used

  1. Couchbase server 4.0 to 4.6 (All Versions)
  2. Sync Gateway 1.3.0 to 1.4.1 (All Versions)
  3. Couchbase lite 1.3 to 1.4.1 (All Versions)

But issue is not gone…

Have you enabled sync logging on the devices and looked at the logs for clues?

To elaborate on what Jens said, please refer to global log settings

Yes.We have enabled everything.CBLRestPuller and CBLRestPusher is running but not able to fetch the new changes.The _changes native couchbase function returns zero changes.The document has been pushed to the server successfully.But when we checked the documents on the server it comes in the _changes API.But the native puller not fetching any new data.

The _changes native couchbase function returns zero changes.

Generally that means the document hasn’t been assigned to any channels that the client’s user account has access to.

_changes from native give zero changes and at the same from the server we are getting changes from _changes when we logged in from my user and password on the server, So I think I have the correct channels and access for the document because on the server I checked my channels and roles admin channels and admin roles they are correct.
And after some time or some hours how the document sync to the device I have no idea where the actual problem is?

Too many times updation or deletion of document are not sync to the device, the document revision is lesser than the document saved on server.

By “native Couchbase function” I thought you meant from the server. But it sounds like you mean the local REST API’s _changes? Does that mean you’re using PhoneGap?

You say you’ve turned sync logging. What’s logged when the document is added to the server? Any warnings? Any indication that the client is pulling new data?

No we are not using Phonegap , We are using Android and IOS. I am repeating my words.
http://user:password@server:port/db/_changes ->> . Gives me all correct result
http://server:adminport/db/_user/username ->> . Gives me all correct Channels
BUT, in my android and ios cbl don’t pull the document from the server, I am getting db changes is ZERO.
I am already enabled the logging.
When I added a document on server, I am not getting any changes not any error, after some time or hours I am getting the document, After this, when I update the document on device or on server don’t matter, it will push but not pulled from the server to other device or my device.

If you’re not using PhoneGap, what exactly is the “_changes native Couchbase function” you’re calling that gives zero changes? Please be specific about what you’re doing.

I am already enabled the logging.

I know. I’m asking you to look at the logs and see what is reported at the time the document is added on the server. Or if you can’t make any sense of them, upload them someplace and post a link. But indicate what exact moment the document was added to the server.

“_changes native Couchbase function” is the couchbase kCBLReplicationChangedNotification.It gives zero changes in the CBLRestPuller.All channels and roles is already assigned to the particular document.

i am giving you log file attached below. (2.6 KB)

In the attached file, i have created a document from device A which needs to be sent to device B with help of sync gateway.Device A successfully created the document and sent to server.Server has assigned roles and channels successfully.But the device B did not get the document.When we check the document on the server it is not conflicted at all.Also, it has channels and roles.The device B CBLRestPuller not showing any changes.Sometimes changes come after 2 hours sometimes after 5 hours and sometimes it will never come.

Are the logs from device B? They only show a pusher, not a puller, which sounds like device A. To be clear, I need to see the logs from the device that’s having trouble pulling.

I am giving you the logs of device B.

Here i have a scenario. Device A updates some document which is successfully updated on the server as well as on (7.4 KB)
other device.The documents on the sever has 10th revision.Other device has same revision too.But on device B it has 6th revision and on other device C it has 4th revision.The puller is not showing any kind of error.

This problem occurs anytime and any type of documents.

Also, please find the attached log file which shows puller of device B.

Thanks for the logs. There are some replicator errors and warnings logged there, which is why I suggested you take a look at the logs in my first message back on Tuesday. It would have sped the diagnosis up a lot if you’d grepped for “warning” and “error”, and posted the relevant lines. (I’m not saying this to make you feel bad, just to let you know how to communicate issues more efficiently.)

This looks like an issue on the Sync Gateway side — the document appears in its changes feed, but it’s unable to find the document when CBL requests it. I seem to recall hearing about an issue like this relating to attachments, where SG can’t locate one of the doc’s attachments so it can’t send the doc when asked — @adamf, does that ring a bell?

Below are the errors and warnings from the log. (The last one is from the pusher, so it’s not directly related, but it seems to be a similar problem in reverse, where SG can’t accept an upload.)

2017-07-21 11:20:40.898335+0530 Halls[472:108255] RemoteRequest: CBLMultipartDownloader[/hcs/1086997406hxin-10d1b4c0fa43a32b2b7d51a1c02e32a5]: JSON error message is: {"error":"not_found","reason":"missing"}

2017-07-21 11:20:40.898960+0530 Halls[472:108255] CBLMultipartDownloader[/hcs/1086997406hxin-10d1b4c0fa43a32b2b7d51a1c02e32a5]: Got error CBLHTTP[404, "missing", <http://"servername"/1086997406hxin-10d1b4c0fa43a32b2b7d51a1c02e32a5?rev=10-19745404e8ed2ec8e3ecec32a71b1c5a&revs=true&attachments=true&atts_since=%5B%229-fcb56a05f664c8b14cd1587d36447818%22%5D>]

2017-07-21 11:20:40.899474+0530 Halls[472:108255] Sync: Giving up on {1086997406hxin-10d1b4c0fa43a32b2b7d51a1c02e32a5 #10-19745404e8ed2ec8e3ecec32a71b1c5a}: CBLHTTP[404, "missing", <http://"servername"/1086997406hxin-10d1b4c0fa43a32b2b7d51a1c02e32a5?rev=10-19745404e8ed2ec8e3ecec32a71b1c5a&revs=true&attachments=true&atts_since=%5B%229-fcb56a05f664c8b14cd1587d36447818%22%5D>]

2017-07-21 11:20:40.902711+0530 Halls[472:108255] WARNING: CBLRestPusher[http://"servername"]: _bulk_docs got an error: { error = "bad_request"; id = 919568555486; reason = "Missing data of attachment \"919568555486.jpg\""; status = 400; } {at __40-[CBLRestPusher uploadBulkDocs:changes:]_block_invoke:402}

This is different document.It does not have any link with the document i pushed to the server from device A. Also, the device B which needs to be pull the document.
The documents which is showing error is may be due to deletion of the document on the server.
Also, i want to ask one more thing.Is there any link between pulling the documents from the server and the error you shown above?

It would be better to focus on one issue at a time. We need to see server logs showing the issue you first reported. I’ve been asking for nearly a week about those logs. It’s not urgent for me, of course, but you probably want to get this issue resolved soon, right?

I think it would be best if you filed an issue against Sync Gateway on Github, since it does look from the above as though there’s something going wrong there.

sorry for replying late, as you have suggested, i have filed an issue on the Github.

@yuvrajsorav, have you got any useful insights upon filling the issue on Github? I’ve been encountering pretty similar issue with syncing on android device but couldn’t get to work it out let me know if you’ve anything for me. Thanks : )


Can you please share specifics of the platform versions, what you were trying to do and the relevant logs.

have you got any useful insights upon filling the issue on Github? I’ve been encountering pretty similar issue with syncing on the android device but couldn’t get to work it out let me know if you’ve anything for me. Thanks : )

Update: Nachdem ich die Apps deinstalliert und neu installiert habe, laufen sie nun wieder normal :slight_smile: