seigel / pouchdb-react-native

Pouchdb with async storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error - Can't sync my localDB with a couch DB in my RN project

paulbx81 opened this issue · comments

Issue

I tried to sync my localDB with a couch DB which is installed into my computer and it work perfectly.

Now i want to do it with a couch DB which is installed into a server.

so i use this code :

    db.sync('https://'userID':'userPASS'@'serverIP':6984/DBname', {
      live: true
    }).on('change', function (change) {
      console.log(change);
    }).on('error', function (err) {
      console.log(err);
    }).on('complete', function (info) {
      console.log(info);
    });
  }

THIS CODE WORK PERFECTLY WHEN I USE IT INTO WEB PROJECT IN INDEX.HTML
but if i use it in my react-native project i have this issue in JS debugger :

CustomPouchError {
    status: 0, name: "unknown",
    message: "getCheckpoint rejected with ",
    result: {…}
}

Info

  • React-Native
  • Windows 10

Reproduce

    db.sync('https://'userID':'userPASS'@'serverIP':6984/DBname', {
      live: true
    }).on('change', function (change) {
      console.log(change);
    }).on('error', function (err) {
      console.log(err);
    }).on('complete', function (info) {
      console.log(info);
    });
  }

I had this exact issue this week. I got closer by importing pouchdb-authentication

https://github.com/pouchdb-community/pouchdb-authentication

It successfully connects and I can dump the remote docs to the console, but I can't get a local db in my RN app to sync with the remote db, it red-screens.

I submitted an issue here ( pouchdb-community/pouchdb-authentication#241 )

I'll keep you posted if I figure it out and if you get it to work, please let me know too, I'd appreciate it.

it work now, the problem was : i didn't have a REAL SSL Certificate for my https.
I don't use pouchdb-authentication. When we want to call a couchDB in other domain, it's necessary to enable CORS in this couchDB and to have a real ssl certificate for using HTTPS and not HTTP

Are you still using your server's IP address in the RN code in the sync command, or did you change it to the domain name in your cert? BTW, curious, who did you use for your new SSL cert?

and are you using pouchdb-react-native ?

Sorry for all the questions

i change it to my domain name with https
And yes i use pouchdb-react-native

So it's the problem solved?

it work now, the problem was : i didn't have a REAL SSL Certificate for my https.
I don't use pouchdb-authentication. When we want to call a couchDB in other domain, it's necessary to enable CORS in this couchDB and to have a real ssl certificate for using HTTPS and not HTTP

Im trying to test with local host using http, Do I have to use https?