android - 在复制期间在 couch base lite 的 android 模拟器中获取 http 404 错误

标签 android couchbase couchbase-lite

在我的 Mac 10.9.2 中 我安装了 couch base 服务器,它正在 http://127.0.0.1:8091 上运行 它有它的默认桶,包括啤酒 sample

我启动同步服务器为

./sync_gateway -bucket="beer-sample" 

在控制台中记录以下内容

14:00:55.903306 ==== Couchbase Sync Gateway/0.94 ====
14:00:55.979850 Configured Go to use all 2 CPUs; setenv GOMAXPROCS to override this
14:00:55.979985 Configured MaxFileDescriptors (RLIMIT_NOFILE) to 5000
14:00:56.005329 Opening db /beer-sample as bucket "beer-sample", pool "default", server <walrus:>
14:00:56.019242 Opening Walrus database beer-sample on <walrus:>
14:00:56.057276 Using default sync function 'channel(doc.channels)' for database "beer-sample"
14:00:56.057549 Starting profile server on 
14:00:56.057680 Starting admin server on 127.0.0.1:4985
14:00:56.090556 Starting server on :4984 ...

在android中我的复制代码看起来像

Replication pullReplication = database.createPullReplication("http://10.0.2.2:4984");
pullReplication.start();

然后我在模拟器中运行我的 android 应用程序,我记录了错误,如 changeEventListener

        if (!replication.isRunning()){
            Log.d(TAG, "Replication is not running due to " + replication.getLastError().getMessage());
            Log.d(TAG, "Replication is not running due to " + replication.getLastError().getCause());
            Log.d(TAG, "Replication is not running due to " + replication.getLastError().getStackTrace());
            Log.d(TAG, "Replication is not running due to " + replication.getLastError().toString());
        }

记录

04-04 14:04:18.402    1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication: Puller[http://10.0.2.2:4984] changed.
04-04 14:04:18.432    1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication is not running due to HTTP/1.1 404 Not Found
04-04 14:04:18.454    1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication is not running due to null
04-04 14:04:18.502    1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication is not running due to [Ljava.lang.StackTraceElement;@414efc88
04-04 14:04:18.502    1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication is not running due to com.couchbase.lite.CouchbaseLiteException: HTTP/1.1 404 Not Found

Note: I am using 10.0.2.2 instead of 127.0.0.1 because i read in forum that's how simulator maps the host machine. But i also tried 127.0.0.1 earlier which also gives the same result.

与此同时,我在同步网关控制台中看到一个新条目,如

14:05:13.532393 HTTP:  #006: GET /_changes?feed=normal&heartbeat=300000

我试着在类似

的浏览器中重复这个查询
> http://127.0.0.1:4984/_changes?feed=normal&heartbeat=300000

正在显示

{"error":"not_found","reason":"unknown URL"}

我在这里做错了什么?我是沙发基地的新手。

最佳答案

设法克服了这个错误:

https://github.com/couchbaselabs/GrocerySync-Android找到一个引用项目

对我的原始步骤/代码所做的主要更改是

  1. 执行同步网关为 ./sync_gateway -bucket="beer-sample"-url=“http://localhost:8091/beer-sample” -verbose

  2. 在同步 URL 中添加了数据库,例如“http://10.0.2.2:4984/beer-sample”,即 database.createPullReplication("http://10.0 .2.2:4984/啤酒样本");

  3. 遇到授权错误。通过在终端中执行以下命令来让匿名访问(暂时)启用 GUEST 帐户

    curl -X PUT localhost:4985/beer-sample/_user/GUEST --data '{"disabled":false, "admin_channels":["public"]}'

关于android - 在复制期间在 couch base lite 的 android 模拟器中获取 http 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22857870/

相关文章:

java - Couchbase 找不到存储桶本地实例

google-app-engine - 限制对 SyncGateway 的 Admin REST API 的访问

database - 数据库的选择

database - 在 Couchbase 中使用 N1QL 从对象的对象中获取所有唯一键

android - 如何在本地删除文档以便服务器在 couches 服务器中保留副本

swift2 - 如何使用 Swift 实现双向绑定(bind)?

android - 桌面游戏上的 Google Play 游戏服务

android - 填充标题文本框后,ListView 页脚元素不可单击

android - 无法显示警报对话框

android - 如何在JAVA中使编辑文本不可编辑但可点击