Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspite of socket connection being established, sync is not functioning. #33

Open
clydemendonca opened this issue Apr 3, 2018 · 0 comments

Comments

@clydemendonca
Copy link

The project in question is using 11 PouchDBs. Inorder to ensure syncing, all 11 DBs were instantiated (with sync) when the Angular 5 application was loaded/bootstrapped. Since sync did not function (due to the limitations set by browsers) we moved towards socket-pouch as a solution. We disabled sync on all DBs and incorporated socket-pouch sync to only one DB. The socketPouchServer runs on localhost:5000 & the CouchDB is hosted on DigitalOcean.

On running the system,
the following logs are observed in the browser. As you can see, an "aborting" error is being logged.
screen shot 2018-04-03 at 5 27 15 pm
the code for the same is

import PouchDB from 'pouchdb';
import PouchDBFind from 'pouchdb-find';
import SocketPouchClient from 'socket-pouch/client';

PouchDB.plugin(PouchDBFind);
PouchDB.adapter('socket', SocketPouchClient);
PouchDB.debug.enable('pouchdb:socket:*');

this.dailyMovementDB = new PouchDB(`${username}_${environment.REQUIRED_DB_VERSION_NUMBER}_daily-movement`, { auto_compaction: true });
        this.dailyMovementDBRemote = new PouchDB(
        {
            adapter: 'socket',
            name: `${username}_${environment.REQUIRED_DB_VERSION_NUMBER}_daily-movement`,
            url: `${environment.REMOTE_COUCH_DB_BASE_URL}`
        });

        var syncHandler = this.dailyMovementDB.replicate.to(this.dailyMovementDBRemote
        ).on('change', function (change) {
            // yo, something changed!
            console.log('yo, something changed', change);
            instance.autosaveMessageService.syncingProcessEndedSubject.next(false);
        }).on('paused', function (info) {
            console.log('replication was paused, usually because of a lost connection', info);
            // replication was paused, usually because of a lost connection
            instance.autosaveMessageService.syncingProcessEndedSubject.next(true);
        }).on('active', function (info) {
            // replication was resumed
            console.log('replication was resumed', info);
            instance.autosaveMessageService.syncingProcessStartedSubject.next();
        }).on('denied', function (info) {
            // handle complete
            console.log('denied', info);
            instance.autosaveMessageService.syncingProcessEndedSubject.next(false);
        }).on('complete', function (info) {
            // handle complete
            console.log('handle complete', info);
            instance.autosaveMessageService.syncingProcessEndedSubject.next(false);
        }).on('error', function (err) {
            console.log(err);
            // instance.createDailyMovementPouchDBs(username);
            // totally unhandled error (shouldn't happen)
        });

And the following logs appear on localhost:5000 (socketPouchServer)
screen shot 2018-04-03 at 5 27 41 pm

the following is the code for the socketPouchServer

var socketPouchServer = require('socket-pouch/server');

const PouchDB = require('pouchdb');

socketPouchServer.listen(5000, {
    remoteUrl: 'http://remoteurl:5984',
}, () => {
    console.log('Hi');
});

Please guide how to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant