Re: Unable to replicate from couchDB. Error 404

221 views
Skip to first unread message

Jens Alfke

unread,
Aug 22, 2012, 5:31:30 PM8/22/12
to mobile-c...@googlegroups.com

On Aug 22, 2012, at 2:22 PM, aat <ambuj...@gmail.com> wrote:

> However, I get Error 404 when I try to do it from tablet. I think it is because of "_changes?feed=normal&heartbeat=300000" being appended at the end of the URL by getChangesFeedPath(). I am not sure why it gets appended at the end of the URL.

That's the URL of the _changes feed of the database, which the replicator accesses to find out what's changed since the last replication.

It looks like it's getting a 404 trying to get that URL. What happens if you try to get it via 'curl'?

Also, I'm not sure whether the Android version of TouchDB supports embedding username/password into the URL like that.

—Jens

Marty Schoch

unread,
Aug 22, 2012, 5:32:01 PM8/22/12
to mobile-c...@googlegroups.com
On Wed, Aug 22, 2012 at 5:22 PM, aat <ambuj...@gmail.com> wrote:
> Hi,
>
> I am trying to replicate CouchDB database to touchDb on an Android tablet. I
> am using the code below. I can access the database on the couchDB using
> curl. However, I get Error 404 when I try to do it from tablet. I think it
> is because of "_changes?feed=normal&heartbeat=300000" being appended at the
> end of the URL by getChangesFeedPath(). I am not sure why it gets appended
> at the end of the URL. Would appriciate any help in understanding where I am
> going wrong.

That is the path to the changes feed for the remote database, which is
used by a pull replicator to identify changes that need to be
replicated.

Are you sure the remote database exists at this address? Accessing
the same URL with curl would be a useful test to run.

Authentication could also be an issue, but I don't think that would
result in a 404.

marty

aat

unread,
Aug 22, 2012, 5:36:42 PM8/22/12
to mobile-c...@googlegroups.com
To add:

I was able to run the com.couchbase.touchdb.testapp.tests.Replicator.java without any issues. My local-test.properties configuration:

replicationTestsEnabled=false

replicationProtocol=http

replicationServer=10.15.1.96

replicationPort=5984

replicationDatabase=touchdb-test

replicationAdminUser=user1

replicationAdminPassword=user1

CURL output:

curl -X GET http://user1:us...@10.15.1.96:5984/serverdb 

{"db_name":"serverdb","doc_count":1,"doc_del_count":0,"update_seq":2,"purge_seq":0,"compact_running":false,"disk_size":8287,"data_size":282,"instance_start_time":"1345663164719115","disk_format_version":6,"committed_update_seq":2}

--Thank you

On Wednesday, August 22, 2012 5:22:51 PM UTC-4, aat wrote:
Hi,

I am trying to replicate CouchDB database to touchDb on an Android tablet. I am using the code below. I can access the database on the couchDB using curl. However, I get Error 404 when I try to do it from tablet. I think it is because of "_changes?feed=normal&heartbeat=300000" being appended at the end of the URL by getChangesFeedPath(). I am not sure why it gets appended at the end of the URL. Would appriciate any help in understanding where I am going wrong.

@Override
    public void onCreate(Bundle savedInstanceState) 
    {
   
    // start TouchDB
        TDServer touchDBserver = null;
        String filesDir = getFilesDir().getAbsolutePath();
        try
        {
          touchDBserver = new TDServer(filesDir);
        } 
        catch (IOException e) 
        {
          Log.e("EXP", "Error starting TDServer", e);
        }
   
        URL remote = null;
    try 
    {
    catch (MalformedURLException e) 
    {
e.printStackTrace();
}
   
        // create a local database
        TDDatabase database = null;
        database = touchDBserver.getDatabaseNamed("serverdb",true);
        boolean tabletTouchDBstatus = database.open();
        System.out.println("**Status of TouchDb on tablet: "+tabletTouchDBstatus);
        
        final TDReplicator repl = database.getReplicator(remote, false, false);    
        repl.start();
       
        String lastSequence = repl.getLastSequence();
        System.out.println("lastSequence"+lastSequence);
   
    }

08-22 17:14:49.391: D/dalvikvm(17295): Trying to load lib /data/data/wgen.net.touchcouch/lib/libcom_couchbase_touchdb_TDCollateJSON.so 0x410f2900
08-22 17:14:49.391: D/dalvikvm(17295): Added shared lib /data/data/wgen.net.touchcouch/lib/libcom_couchbase_touchdb_TDCollateJSON.so 0x410f2900
08-22 17:14:49.391: V/TDCollateJSON(17295): SQLite3 handle is 1531733624
08-22 17:14:49.391: I/System.out(17295): **Status of TouchDb on tablet: true
08-22 17:14:49.391: V/TDDatabase(17295): TDPuller[http://user1:user1@10.15.1.96:5984/severdb] STARTING ...
08-22 17:14:49.391: W/TDDatabase(17295): TDPuller[http://user1:user1@10.15.1.96:5984/severdb] starting ChangeTracker with since=null
08-22 17:14:49.391: I/System.out(17295): lastSequencenull
08-22 17:14:49.391: D/AndroidRuntime(17295): Shutting down VM
08-22 17:14:49.391: W/dalvikvm(17295): threadid=1: thread exiting with uncaught exception (group=0x40b0b300)
08-22 17:14:49.391: E/AndroidRuntime(17295): FATAL EXCEPTION: main
08-22 17:14:49.391: E/AndroidRuntime(17295): android.app.SuperNotCalledException: Activity {wgen.net.touchcouch/wgen.net.touchcouch.MainActivity} did not call through to super.onCreate()
08-22 17:14:49.391: E/AndroidRuntime(17295): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
08-22 17:14:49.391: E/AndroidRuntime(17295): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-22 17:14:49.391: E/AndroidRuntime(17295): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-22 17:14:49.391: E/AndroidRuntime(17295): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-22 17:14:49.391: E/AndroidRuntime(17295): at android.os.Handler.dispatchMessage(Handler.java:99)
08-22 17:14:49.391: E/AndroidRuntime(17295): at android.os.Looper.loop(Looper.java:137)
08-22 17:14:49.391: E/AndroidRuntime(17295): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-22 17:14:49.391: E/AndroidRuntime(17295): at java.lang.reflect.Method.invokeNative(Native Method)
08-22 17:14:49.391: E/AndroidRuntime(17295): at java.lang.reflect.Method.invoke(Method.java:511)
08-22 17:14:49.391: E/AndroidRuntime(17295): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-22 17:14:49.391: E/AndroidRuntime(17295): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-22 17:14:49.391: E/AndroidRuntime(17295): at dalvik.system.NativeStart.main(Native Method)
08-22 17:14:49.401: V/TDDatabase(17295): Making request to http://user1:us...@10.15.1.96:5984/severdb/_changes?feed=normal&heartbeat=300000
08-22 17:14:49.451: E/TDDatabase(17295): Change tracker got error 404
08-22 17:14:49.451: D/TDDatabase(17295): changed tracker asked to stop
08-22 17:14:49.451: D/TDDatabase(17295): change tracker in stopped
08-22 17:14:49.451: D/TDDatabase(17295): posting stopped
08-22 17:14:49.461: D/dalvikvm(17295): GC_CONCURRENT freed 312K, 6% free 6190K/6535K, paused 15ms+1ms, total 57ms
08-22 17:14:49.461: W/TDDatabase(17295): TDPuller[http://user1:user1@10.15.1.96:5984/severdb]: ChangeTracker stopped
08-22 17:14:49.461: V/TDDatabase(17295): TDPuller[http://user1:user1@10.15.1.96:5984/severdb] STOPPED
08-22 17:14:49.461: D/TDDatabase(17295): change tracker client should be null now
08-22 17:14:49.461: V/TDDatabase(17295): Change tracker run loop exiting
08-22 17:14:51.221: I/Process(17295): Sending signal. PID: 17295 SIG: 9

Thanks..
AAT

Marty Schoch

unread,
Aug 22, 2012, 5:42:19 PM8/22/12
to mobile-c...@googlegroups.com
On Wed, Aug 22, 2012 at 5:36 PM, aat <ambuj...@gmail.com> wrote:
> To add:
>
> I was able to run the com.couchbase.touchdb.testapp.tests.Replicator.java
> without any issues. My local-test.properties configuration:
>
> replicationTestsEnabled=false
>
> replicationProtocol=http
>
> replicationServer=10.15.1.96
>
> replicationPort=5984
>
> replicationDatabase=touchdb-test
>
> replicationAdminUser=user1
>
> replicationAdminPassword=user1
>
> CURL output:
>
> curl -X GET http://user1:us...@10.15.1.96:5984/serverdb
>
> {"db_name":"serverdb","doc_count":1,"doc_del_count":0,"update_seq":2,"purge_seq":0,"compact_running":false,"disk_size":8287,"data_size":282,"instance_start_time":"1345663164719115","disk_format_version":6,"committed_update_seq":2}

Thanks, can you run two more curl commands

curl -X GET "http://user1:us...@10.15.1.96:5984/severdb/_changes?feed=normal&heartbeat=300000"

and

curl -X GET "http://10.15.1.96:5984/severdb/_changes?feed=normal&heartbeat=300000"

Curious to see if you get 404 or some error status if the auth
credentials are wrong.

marty

aat

unread,
Aug 22, 2012, 5:49:53 PM8/22/12
to mobile-c...@googlegroups.com
Hi,

Here are the o/p:
{"error":"not_found","reason":"no_db_file"}

{"error":"not_found","reason":"no_db_file"}

Marty Schoch

unread,
Aug 22, 2012, 6:02:09 PM8/22/12
to mobile-c...@googlegroups.com
On Wed, Aug 22, 2012 at 5:49 PM, aat <ambuj...@gmail.com> wrote:
> Hi,
>
> Here are the o/p:
>
> curl -X GET
> "http://user1:us...@10.15.1.96:5984/severdb/_changes?feed=normal&heartbeat=300000"
>
> {"error":"not_found","reason":"no_db_file"}
>
> curl -X GET
> "http://10.15.1.96:5984/severdb/_changes?feed=normal&heartbeat=300000"
>
> {"error":"not_found","reason":"no_db_file"}

Thanks, this seems kinda strange.

How about if you just access:

http://user1:us...@10.15.1.96:5984/severdb/_changes

If the database exists and the user has access this should return data.
If the database exists and the user does not have access it should
return HTTP 401.
And if the database doesn't exist it should return 404.

In addition to running that command, can you elaborate on any security
settings you have made/changed?

marty

aat

unread,
Aug 22, 2012, 6:28:33 PM8/22/12
to mobile-c...@googlegroups.com

I am not sure what the issue was. I restarted couchDB and removed user1 and tried with the admin user. The app works now.  Here is the o/p


{"results":[
{"seq":2,"id":"Student1","changes":[{"rev":"2-8fd8b658774f80455816975929c8f66c"}]}
],
"last_seq":2}

 Thank you for all the help.
Reply all
Reply to author
Forward
0 new messages