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

Android: setCredential not working #78

Open
Galaloo opened this issue Aug 2, 2014 · 6 comments
Open

Android: setCredential not working #78

Galaloo opened this issue Aug 2, 2014 · 6 comments

Comments

@Galaloo
Copy link

Galaloo commented Aug 2, 2014

Using setCredential does not work.

//replication works
    //var pullReplicate = db.createPullReplication('https://aaatest:[email protected]/aaatest');

//replication does not work
    var pullReplicate = db.createPullReplication('https://prepandpantry.iriscouch.com/aaatest');
    pullReplicate.setCredential({ user: 'aaatest', pass: 'aaatest' });

    pullReplicate.continuous = true;

    pullReplicate.addEventListener('status', function(e) {
        Ti.API.info('syncing Changes ' + pullReplicate.completedChangesCount);
    });

    pullReplicate.start();

Throws the following errors, but not the 'ChangeTracker' errors.

[[ERROR] :  RemoteRequest: Got error status: 404 for org.apache.http.client.methods.HttpGet@52a84658.  Reason: Object Not Found
[DEBUG] :  dalvikvm: GC_FOR_ALLOC freed 1933K, 20% free 8907K/11056K, paused 4ms, total 5ms
[ERROR] :  E/        : UID 10050 asks for /proc/cpuinfo
[ERROR] :  E/        : Unable to open file /data/data/.appwithABI2
[ERROR] :  E/        : Unable to open file /data/data/.appwithABI2neon
[ERROR] :  E/        : UID 10050 is not in ARM UID list files
[WARN] :   EGL_genymotion: eglSurfaceAttrib not implemented
[ERROR] :  RemoteRequest: Got error status: 404 for org.apache.http.client.methods.HttpGet@52ab0534.  Reason: Object Not Found
[ERROR] :  Sync: com.couchbase.lite.replicator.Replication$4@52aeded8: Session check failed
[ERROR] :  Sync: org.apache.http.client.HttpResponseException: Object Not Found
[ERROR] :  Sync:    at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:228)
[ERROR] :  Sync:    at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:106)
[ERROR] :  Sync:    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
[ERROR] :  Sync:    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
[ERROR] :  Sync:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
[ERROR] :  Sync:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
[ERROR] :  Sync:    at java.lang.Thread.run(Thread.java:841)
[ERROR] :  Sync: Puller@52a8175c[https://prepandpantry.iriscouch.com/aaatest]: Progress: set error = org.apache.http.client.HttpResponseException: Object Not Found
[INFO] :   syncing Changes 0
[INFO] :   syncing Changes 0
[WARN] :   TiVerify: (Timer-0) [5001,5001] Verifying module licenses...
[INFO] :   TiVerify: (Timer-0) [648,5649] Succesfully verified module licenses
[INFO] :   APSAnalyticsService: Analytics Service Started
[INFO] :   APSAnalyticsService: Stopping Analytics Service
[ERROR] :  Sync: Puller@52a8175c[https://prepandpantry.iriscouch.com/aaatest]: Progress: set error = null
[INFO] :   syncing Changes 0

Studio 3.3
SDK 3.3.0.GA
Android Ti_touchdb 1.0.1

@pegli
Copy link
Collaborator

pegli commented Aug 26, 2014

Can you try this with a build from the current develop branch or the 1.1 build when I release it? I was able to successfully replicate from your aaatest database on the Android emulator after updating the Couchbase Mobile for Android JAR files to version 1.0.2. I do see the following errors on the first replication:

[ERROR] RemoteRequest: Got error status: 404 for https://prepandpantry.iriscouch.com/aaatest/_session.  Reason: Object Not Found
[ERROR] RemoteRequest: Got error status: 404 for https://prepandpantry.iriscouch.com/aaatest_session.  Reason: Object Not Found
[ERROR] Sync: com.couchbase.lite.replicator.Replication$4@b23f0170: Session check failed
[ERROR] Sync: org.apache.http.client.HttpResponseException: Object Not Found
[ERROR] Sync:   at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:226)
[ERROR] Sync:   at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:106)
[ERROR] Sync:   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
[ERROR] Sync:   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
[ERROR] Sync:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
[ERROR] Sync:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
[ERROR] Sync:   at java.lang.Thread.run(Thread.java:841)
[ERROR] Sync: Puller@b2390698[https://prepandpantry.iriscouch.com/aaatest]: Progress: set error = org.apache.http.client.HttpResponseException: Object Not Found

However, after a few minutes, the replicator kicks in again and pulls all of the documents down.

@Galaloo
Copy link
Author

Galaloo commented Aug 26, 2014

Will do. I'll check it out with the next build.

@webfrank
Copy link

Hi, I got the same problem with 1.2.0.

If I specify the remote URL like this http://192.168.0.179:5984/ (without dbname) I got:
[ERROR] : Sync: com.couchbase.lite.replicator.ReplicationInternal$4@42c33f50 checkSessionAtPath() response: {ok=true, userCtx={name=couchtest, roles=[salonuser]}, info={authentication_db=_users, authentication_handlers=[oauth, cookie, default], authenticated=default}}
[ERROR] : Sync: com.couchbase.lite.replicator.ReplicationInternal$4@42b78748 checkSessionAtPath() response: {ok=true, userCtx={name=couchtest, roles=[salonuser]}, info={authentication_db=_users, authentication_handlers=[oauth, cookie, default], authenticated=default}}
[ERROR] : RemoteRequest: Got error status: 400 for http://192.168.0.179:5984/_local/2ca042989e5902f6394b1314a1b860217834a9a6. Reason: Bad Request
[WARN] : Sync: com.couchbase.lite.replicator.ReplicationInternal$9@42c8c4c0: error getting remote checkpoint
[ERROR] : Sync: com.couchbase.lite.replicator.PullerInternal@428c1f28: Progress: set error = org.apache.http.client.HttpResponseException: Bad Request
[ERROR] : RemoteRequest: Got error status: 400 for http://192.168.0.179:5984/_local/a008d8f2b65d172a896758ced686cdb3e15fd593. Reason: Bad Request
[WARN] : Sync: com.couchbase.lite.replicator.ReplicationInternal$9@42c8c700: error getting remote checkpoint
[ERROR] : Sync: com.couchbase.lite.replicator.PusherInternal@42b73a08: Progress: set error = org.apache.http.client.HttpResponseException: Bad Request
[ERROR] : Sync: PullerInternal stopGraceful.run() finished
[ERROR] : Sync: PusherInternal stopGraceful.run() finished

and replication cannot start because it does not have the db name.

If I use the correct URL like this http://192.168.0.179:5984/couchtest I got this error:

[ERROR] : DataScheduler: isDataSchedulerEnabled():false
[ERROR] : DataScheduler: isDataSchedulerEnabled():false
[ERROR] : RemoteRequest: Got error status: 404 for http://192.168.0.179:5984/couchtest/_session. Reason: Object Not Found
[ERROR] : RemoteRequest: Go
[ERROR] : RemoteRequest: Got error status: 404 for http://192.168.0.179:5984/couchtest_session. Reason: Object Not Found
[ERROR] : Sync: com.couchbase.lite.replicator.ReplicationInternal$4@42a54b60: Session check failed
[ERROR] : Sync: org.apache.http.client.HttpResponseException: Object Not Found
[ERROR] : Sync: at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:217)
[ERROR] : Sync: at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:101)
[ERROR] : Sync: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
[ERROR] : Sync: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
[ERROR] : Sync: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
[ERROR] : Sync: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
[ERROR] : Sync: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
[ERROR] : Sync: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
[ERROR] : Sync: at java.lang.Thread.run(Thread.java:841)
[ERROR] : Sync: com.couchbase.lite.replicator.PullerInternal@429fcb68: Progress: set error = org.apache.http.client.HttpResponseException: Object Not Found
[ERROR] : RemoteRequest: Got error status: 404 for http://192.168.0.179:5984/couchtest_session. Reason: Object Not Found
[ERROR] : Sync: com.couchbase.lite.replicator.ReplicationInternal$4@42a54420: Session check failed
[ERROR] : Sync: org.apache.http.client.HttpResponseException: Object Not Found
[ERROR] : Sync: at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:217)
[ERROR] : Sync: at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:101)
[ERROR] : Sync: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
[ERROR] : Sync: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
[ERROR] : Sync: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
[ERROR] : Sync: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
[ERROR] : Sync: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
[ERROR] : Sync: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
[ERROR] : Sync: at java.lang.Thread.run(Thread.java:841)
[ERROR] : Sync: com.couchbase.lite.replicator.PusherInternal@429ea8a8: Progress: set error = org.apache.http.client.HttpResponseException: Object Not Found

As you can see the library tries to open the wrong path to _session api (it does not remove the dbname)

@webfrank
Copy link

After opening a ticket on couches-lite-java-core it has been just fixed, here is the link:

couchbase/couchbase-lite-java-core@0ffce45

@pegli
Copy link
Collaborator

pegli commented Nov 28, 2014

I've rebuilt the module with the latest couchbase-lite-android and couchbase-lite-java-core source and have updated the 1.2.1. pre-release module ZIP file. Can you download the new build and try it out? Note that, because the version number hasn't changed, you will need to completely clean your project, and should probably delete the old modules/android/com.obscure.titouchdb directory as well to ensure that the new code is being run. Once Couchbase releases a new version of the Android libraries, I'll make a new build of 1.2.1 and mark it as an actual release.

@webfrank
Copy link

Hi, sorry for late check but now replication with credentials works as expected. Tnx for support.

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

3 participants