pouchdb-react-native icon indicating copy to clipboard operation
pouchdb-react-native copied to clipboard

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

Open paulbx81 opened this issue 6 years ago • 7 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);
    });
  }

paulbx81 avatar Jul 31 '18 09:07 paulbx81

@stockulus

paulbx81 avatar Aug 02 '18 12:08 paulbx81

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 ( https://github.com/pouchdb-community/pouchdb-authentication/issues/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.

jwheat avatar Aug 07 '18 20:08 jwheat

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

paulbx81 avatar Aug 08 '18 07:08 paulbx81

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

jwheat avatar Aug 08 '18 14:08 jwheat

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

paulbx81 avatar Aug 08 '18 15:08 paulbx81

So it's the problem solved?

mqtik avatar Jan 20 '19 19:01 mqtik

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?

santi8194 avatar Jul 18 '19 19:07 santi8194