couchbaselabs / react-native-couchbase-lite

Couchbase Lite binding for React Native Android & iOS
MIT License
110 stars 53 forks source link

Failed replication on Android: 405 Method Not Allowed #88

Closed adamski closed 8 years ago

adamski commented 8 years ago

I'm struggling to get replication working on Android. I'm replicating from a Cloudant database. The same code works fine for iOS.

My init code:

    ReactCBLite.init((url) => {
      console.log("couchbase lite started at", url)
      // instantiate a new database
      var database = new manager(url, databaseConstants.database)

      console.log("got manager:")
      console.log(manager)

      database.createDatabase()
      .then((res) => {
        console.log("Got database")
        console.log(res)
        return database.replicate(databaseConstants.remoteURL, databaseConstants.database)
      })
      .then(res => console.log(res))
      .then(() => database.getDocuments())
      .then((res) => {
        console.log("Got data:")
        console.log(res)

        // Initialise app...
      })
      .catch((ex) => {
        console.log(ex)
      })
    })

Relevant logs:

W/ChangeTracker: ChangeTracker{https://---:---@mycompany.cloudant.com/mydatabase, OneShot, @df83391}: Change tracker got error 405
W/Sync: PullerInternal{unknown, pull, 8faf5}: Progress: set error = com.couchbase.lite.replicator.RemoteRequestResponseException: Method Not Allowed
W/RemoteRequest: com.couchbase.lite.replicator.RemoteRequest {GET, https://---:---@mycompany.cloudant.com/mydatabase/_local/8faf57b16d7ac5291664ae86e46abfbada4ddcf7}: aborting request: okhttp3.RealCall@58a52f6
I/ReactNativeJS: { session_id: 'repl001' }
I/ReactNativeJS: Got data:
I/ReactNativeJS: { total_rows: 0, offset: 0, rows: [] }
npomfret commented 8 years ago

If you tail the sync gateway logs in your cloudant server can you see the request and corresponding 405?

I think might be better asked in https://github.com/couchbase/couchbase-lite-ios or https://github.com/couchbase/couchbase-lite-android, all this project really does is expose the native REST api to react-native.

adamski commented 8 years ago

Yes I realised that soon after posting. Not sure I can log the requests to Cloudant unfortunately. I will ask at the couchbase-lite-android repository. Thanks

npomfret commented 8 years ago

The sync gateway will be logging (unless you've turned it off of course).

Good luck

adamski commented 8 years ago

I'm not using Sync Gateway - replicating direct from Cloudant, which AFAIK do not provide request logs :-/

adamski commented 8 years ago

https://github.com/couchbase/couchbase-lite-android/issues/992