multiple calls to _replicate

38 views
Skip to first unread message

Seung Chan Lim

unread,
Oct 22, 2014, 10:29:27 PM10/22/14
to mobile-c...@googlegroups.com
I'm curious what the underlying behavior of the phonegap couchdblite plug in is when you make multiple _request http requests. 

My use case is that the session cookie has expired, and I want to make a new _request HTTP request with new cookie headers. What I'm worried is that it is somehow increasing the number of replicate operations many of which are no longer valid due to the expired cookie.

slim

Jens Alfke

unread,
Oct 23, 2014, 12:25:30 AM10/23/14
to mobile-c...@googlegroups.com

On Oct 22, 2014, at 7:29 PM, Seung Chan Lim <djs...@gmail.com> wrote:

I'm curious what the underlying behavior of the phonegap couchdblite plug in is when you make multiple _request http requests. 

You mean _replicate?

CBL won't run more than one "equivalent" replication at a time. Where "equivalent" means the same destination URL, direction, continuousness, filters, etc. If you try to start a second equivalent one the request will be ignored.

—Jens

Seung Chan Lim

unread,
Oct 23, 2014, 11:01:51 AM10/23/14
to mobile-c...@googlegroups.com

If the second request is ignored, what could I do to update its header information, which holds the updated session cookie?

Jens Alfke

unread,
Oct 23, 2014, 4:22:52 PM10/23/14
to mobile-c...@googlegroups.com

On Oct 23, 2014, at 8:01 AM, Seung Chan Lim <djs...@gmail.com> wrote:

If the second request is ignored, what could I do to update its header information, which holds the updated session cookie?

Stop the replication, update the headers, then start it again.

—Jens

Seung Chan Lim

unread,
Oct 24, 2014, 10:42:46 AM10/24/14
to mobile-c...@googlegroups.com
Stop? You mean abort the HTTP call made to http://lite.couchbase./_replicate ?

slim

Jens Alfke

unread,
Oct 24, 2014, 11:53:36 AM10/24/14
to mobile-c...@googlegroups.com

On Oct 24, 2014, at 7:42 AM, Seung Chan Lim <djs...@gmail.com> wrote:

Stop? You mean abort the HTTP call made to http://lite.couchbase./_replicate ?

No, POST to _replicate with the same source/target and adding a "cancel":true property.
Looks like our REST API docs omit most of the properties that _replicate supports; sorry about that. I've filed a ticket.
The CouchDB API docs list more of them including "cancel".

—Jens

Seung Chan Lim

unread,
Oct 24, 2014, 7:28:04 PM10/24/14
to mobile-c...@googlegroups.com
Can a HTTP request to http://lite.coucbase./_replicate with the cancel:true property ever return a 404 despite my having never canceled it manually? For example, could it cancel itself if replication isn't working well (i.e. goes offline due to being unable to reach the sgw or gets a 401 from the sgw).

I'm seeing a 404 returned despite having never canceled it manually...

slim

Jens Alfke

unread,
Oct 24, 2014, 7:54:09 PM10/24/14
to mobile-c...@googlegroups.com

On Oct 24, 2014, at 4:28 PM, Seung Chan Lim <djs...@gmail.com> wrote:

Can a HTTP request to http://lite.coucbase./_replicate with the cancel:true property ever return a 404 despite my having never canceled it manually? For example, could it cancel itself if replication isn't working well (i.e. goes offline due to being unable to reach the sgw or gets a 401 from the sgw).

It'll return a 404 if there's no current replication task with those attributes. So if the replication is a one-shot (not continuous) that either completed or failed with an error, then you would get a 404.

—Jens

Seung Chan Lim

unread,
Oct 24, 2014, 8:26:38 PM10/24/14
to mobile-c...@googlegroups.com
Is there any reason I would get a 404 if it's continous? 

slim
Reply all
Reply to author
Forward
0 new messages