Re: Timed out error during REST replication from external couchDB to Mobile couchbase on iPad

327 views
Skip to first unread message

Jens Alfke

unread,
Nov 9, 2012, 1:50:43 PM11/9/12
to mobile-c...@googlegroups.com

On Nov 9, 2012, at 10:38 AM, Rahul sivasankaran <rahul.si...@gmail.com> wrote:

> I am using apache mobile ios couchbase v 2.0.1 as my application database to hold the offline content.

FYI, we’re not supporting that software anymore; you should consider migrating to TouchDB. It will make your app a lot smaller and faster-launching, too.

> When I am replicating database (PULL) from a remotely located couchDB the request is failing with HTTP error code 500 and reason Timeout on server.
> Replication is happening properly on the iPad and iPhone simulator but on the device its fails.

I suggest setting up a monitoring HTTP proxy like Charles and configuring the device to use it; then you can see what the exact requests and responses look like. That may give you clues.

—Jens

Rahul sivasankaran

unread,
Nov 13, 2012, 9:23:45 AM11/13/12
to mobile-c...@googlegroups.com
Now the couch base replication is successfully taking place and i could see the updated documents 
on iPad simulator. I have tried it through REST based ajax requests and also CouchCocoa and is working fine on iPad simulator for both.

But on the device the replication is not timing out now and is successful. I am getting the response properly but the database is not getting updated. Is there any specific settings required to make it work on the device. Any permission setting to update the database?

Please find the logger statements when I am doing it through CouchCocoa

Nov 13 19:25:56 unknown PortfolioCenter[2107] <Warning>: Couchbase is Ready, go! http://127.0.0.1:53980/
> > 
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: [INFO] base url: http://127.0.0.1:53980/
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: [INFO] sourceurl :http://admin:Unisys123*@ustr-vm-6043.uis.unisys.com:8081/
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: CouchChangeTracker[_replicator]: Starting with request:
GET /_replicator/_changes?feed=continuous&heartbeat=300000&since=3 HTTP/1.1
Host: 127.0.0.1
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: CouchLiveQuery: Starting...
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: CouchLiveQuery: ...Finished (status=200)
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: CouchLiveQuery: ...Rows changed! (now 2)
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: CouchPersistentReplication[(null)] initWithDocument: CouchDocument[08c9..028b] @0x690580
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: CouchPersistentReplication[08c9..028b]: state := error
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: Creating dynamic accessor method -[CouchPersistentReplication source]
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: Creating dynamic accessor method -[CouchPersistentReplication target]
Nov 13 19:26:05 unknown PortfolioCenter[2107] <Warning>: [INFO] afterReplicationSuccess

The following successful response I am getting when using REST but database is not getting updated.

{"ok":true,"id":"4335e8555d26fcba28c87c5be00009df","rev":"1-138a7a6c81d5b14d46f5306d7b80780f"}

As you suggested i set up Charles proxy but i could not figure out what is went wrong because I am using loop back url for replication. Proxy could not
capture the request to couchbase url on the device.

We could not use Touch DB because there are some complexities involved in using .couch files to create the databases.

On Saturday, November 10, 2012 12:08:23 AM UTC+5:30, Rahul sivasankaran wrote:
I am using apache mobile ios couchbase v 2.0.1 as my application database to hold the offline content.
When I am replicating database (PULL)  from a remotely located couchDB the request is failing with HTTP error code 500 and reason Timeout on server.

Replication is happening properly on the iPad and iPhone simulator but on the device its fails.

I am invoking the replication through REST services from my cross platform Sencha Project.


Could anybody provide a solution to this issue?

Jens Alfke

unread,
Nov 13, 2012, 12:20:34 PM11/13/12
to mobile-c...@googlegroups.com
On Nov 13, 2012, at 6:23 AM, Rahul sivasankaran <rahul.si...@gmail.com> wrote:

As you suggested i set up Charles proxy but i could not figure out what is went wrong because I am using loop back url for replication. Proxy could not
capture the request to couchbase url on the device.

Then try putting the database you’re replicating with on a different host, so it doesn’t use the loopback interface.

We could not use Touch DB because there are some complexities involved in using .couch files to create the databases.

I don’t think we can realistically provide in-depth support for Couchbase Mobile anymore. It’s not just that it’s obsolete, but none of us have touched or looked at the code in a long time, so we’re not going to be fluent with the details.

Why do you need to create .couch files?

—Jens

Rahul sivasankaran

unread,
Nov 13, 2012, 11:17:18 PM11/13/12
to mobile-c...@googlegroups.com
I had set up charles proxy on my Mac and configured my wifi connection to use that proxy. Now any  http traffic to the server is getting captured and I can see the details. But I am using device couchbase server URL for replication (127.0.0.1:<Port Name>/_replicator) for replicaton and is never going to access the proxy. So i cant see the details too. I am using PULL for database on the device.
 
 
I am using .couch files from the couchDB on my server to create the databases on the couchbase mobile server so that the databases will be populated with initial content. I think touch DB databases also can be created this way but need to copy the attachments seperately.
 
 

Jens Alfke

unread,
Nov 14, 2012, 2:48:08 PM11/14/12
to mobile-c...@googlegroups.com

On Nov 13, 2012, at 8:17 PM, Rahul sivasankaran <rahul.si...@gmail.com> wrote:

I had set up charles proxy on my Mac and configured my wifi connection to use that proxy. Now any  http traffic to the server is getting captured and I can see the details. But I am using device couchbase server URL for replication (127.0.0.1:<Port Name>/_replicator) for replicaton and is never going to access the proxy. So i cant see the details too. I am using PULL for database on the device.

It’s not the requests your app makes to the local CouchDB instance that are interesting here, it’s the ones the CouchDB replicator sends to the remote server, and those do get captured.

—Jens

Rahul sivasankaran

unread,
Nov 15, 2012, 2:30:56 PM11/15/12
to mobile-c...@googlegroups.com

I am now using TouchDB and Since I am using Sencha Framework for development i need to get the http equivalent URL for TouchDB on device 
to send Ajax requests. I have gone through another topic and found the following code to get the http URL. But i am always getting http://localhost.touchdb./      How can i obtain a url as given below? I could able to use database files from couchDB to populate my database. Thanks for your support.

 NSURL* url = touchServer.URL; 
        url = [TDURLProtocol HTTPURLForServerURL: url]; 

This will give you something like http://server1.touchdb./ . 

Rahul sivasankaran

unread,
Nov 15, 2012, 2:46:31 PM11/15/12
to mobile-c...@googlegroups.com


On Friday, November 16, 2012 1:00:56 AM UTC+5:30, Rahul sivasankaran wrote:

I am now using TouchDB and Since I am using Sencha Framework for development i need to get the http equivalent URL for TouchDB on device 
to send Ajax requests. I have gone through another topic and found the following code to get the http URL. But i am always getting http://localhost.touchdb./      How can i obtain a url as given below? I could able to use database files from couchDB to populate my database. Thanks for your support. When I am using http://localhost.touchdb./   I am getting HTTP 404  (not found) error.

Jens Alfke

unread,
Nov 15, 2012, 4:50:06 PM11/15/12
to mobile-c...@googlegroups.com

On Nov 15, 2012, at 11:30 AM, Rahul sivasankaran <rahul.si...@gmail.com> wrote:

to send Ajax requests. I have gone through another topic and found the following code to get the http URL. But i am always getting http://localhost.touchdb./     How can i obtain a url as given below? I could able to use database files from couchDB to populate my database. Thanks for your support.

 NSURL* url = touchServer.URL; 
        url = [TDURLProtocol HTTPURLForServerURL: url]; 

Did it work? That looks like a valid URL for that method to return.

—Jens

Rahul sivasankaran

unread,
Nov 16, 2012, 10:34:09 AM11/16/12
to mobile-c...@googlegroups.com

I have seen the below piece of code to created TDDatabase instance. But i could not find t1he following interface method available to do it. 

1. CouchTouchDBServer does not have a property to touchServer to use "server.touchServe" to get TDServer instance.
2. TDServer instance does not have a method "databaseNamed".

I have downloaded the latest CouchCocoa and TouchDB. Could you tell me which version support the above?

TDDatabase* mydatabase = [server.touchServer databaseNamed: @“mydatabase”];
if (!mydatabase.exists) {
NSString* dstPath = mydatabase.path;
… copy database out of your bundle to dstPath
… copy attachments directory to its path
}
Reply all
Reply to author
Forward
0 new messages