Couchbase Mobile Replication via REST-API

When trying to integrate couchbase mobile (version 1.1.0) in our hybrid mobile application (ionic), we encountered a problem with push replication on iOS.

At some point in the application (after creating the local database, etc.), a project document with some views is successfully created. Continuous push and pull replication is created and started.

When polling for push replication status, we noticed that it stopped (not normal for continuous replication) shortly after it started.

Couchbase mobile responded with an error (404)

WARNING: CBL_Pusher[http://server:4985/bucket-sync-gateway]: _bulk_docs got an error: { error = "bad_request"; id = "_design/app"; reason = "Invalid doc ID"; status = 400; } 

The synchronization gateway registered a similar error:

 BulkDocs: Doc "_design/app" --> 400 Invalid doc ID (400 Invalid doc ID) 

This only happens on iOS. The Android version has no problems with replication (perhaps project documents are ignored?)

  • Why is replication trying to synchronize project documents with ios and not on android?
  • Should I synchronize project documents?
  • Is there a way to prevent a specific document from syncing? (Native api provides a filtering mechanism for replication, but rest-api does not)

Any idea what could be the problem here?

Greetings

Bert

+6
source share
1 answer

What versions of Couchbase Lite and Sync Gateway are you using? I believe that the behavior has improved in version 1.1 of each of them. In particular, Sync Gateway now returns 403 Forbidden instead of 400 Bad Request when a client tries to download a project document. The Couchbase Lite Replicator will continue to work after this state, and not stop with an error.

Constructive documents are problematic because they usually contain executable code (JavaScript) in the form of display, reduction, or filtering functions. For security reasons, Sync Gateway (such as CouchDB) will not allow a non-administrator client to download it.

Worse, this is most likely a violation of your agreement with Apple so that your iOS application downloads the project document because applications are not allowed to execute the downloaded code. (The reason I say โ€œprobablyโ€ is because the exception is the JavaScript code running in the web browser. The project document contains JS and your PhoneGap application code runs in the browser, but the map / reduce / filter functions they donโ€™t work in a browser, but in a separate JS context caused by Couchbase Lite. Iโ€™m not a lawyer and I have no idea what Apple will think about it. As far as I know, it never appeared.)

-Jens Alfke (Mobile Architect, Couchbase)

+2
source

Source: https://habr.com/ru/post/989799/


All Articles