1

多数のドキュメントがロードされたデータバケットをUbuntu使用して、Couchbase サーバーを実行する VM を作成しました。ships

Androidエミュレータで実行されているCouchbase liteデータベースへのこのデータバケットの簡単なプルをテストしようとしています. しかし、私は多くの問題を抱えています!

config.json同期ゲートウェイを構成するために以下を作成しました

{
    "log":["CRUD+", "REST+", "Changes+", "Attach+"],
    "verbose" : true,
    "databases": {
        "ships": {
            "server":"http://192.168.0.9:8091",
            "sync":`function (doc) { channel (doc.channels); }`,
            "users": {
                "GUEST": {
                    "disabled": false,
                    "admin_channels": ["*"]
                }
            }
        }
    }
}

同期ゲートウェイを起動すると、正常に起動するように見えます

E:\Couchbase>sync_gateway ./data/config.json
2015-08-23T10:00:43.275+01:00 Enabling logging: [CRUD+ REST+ Changes+ Attach+]
2015-08-23T10:00:43.276+01:00 ==== Couchbase Sync Gateway/1.1.0(28;86f028c) ====

2015-08-23T10:00:43.276+01:00 Configured Go to use all 8 CPUs; setenv GOMAXPROCS
 to override this
2015-08-23T10:00:43.277+01:00 WARNING: Error setting MaxFileDescriptors to 5000:
 Unsupported on Windows -- rest.setMaxFileDescriptors() at config.go:443
2015-08-23T10:00:43.277+01:00 Opening db /ships as bucket "ships", pool "default
", server <http://192.168.0.9:8091>
2015-08-23T10:00:43.277+01:00 Opening Couchbase database ships on <http://192.16
8.0.9:8091>
2015/08/23 10:00:43  Trying with selected node 0
2015/08/23 10:00:43  Trying with selected node 0
2015-08-23T10:00:43.374+01:00     Reset guest user to config
2015-08-23T10:00:43.375+01:00 Starting admin server on 127.0.0.1:4985
2015-08-23T10:00:43.379+01:00 Starting server on :4984 ...

MainActivity クラスには、同期 URL を作成する次のメソッドがあります。

private URL createSyncURL(boolean isEncrypted){
    URL syncURL = null;
    String host = "https://10.0.2.2";
    String port = "4984";
    String dbName = "ships";
    try {
        syncURL = new URL(host + ":" + port + "/" + dbName);
    } catch (MalformedURLException me) {
        me.printStackTrace();
    }
    return syncURL;
}

複製プロセスを呼び出す方法としても

    private void startReplications() throws CouchbaseLiteException {
        Replication pull = application.getDatabase().createPullReplication(this.createSyncURL(false));
        pull.setContinuous(true);
        pull.start();

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

startReplications()メソッドを呼び出すと、次の例外が発生します

08-23 09:16:53.034  17976-18002/com.couchbase.examples.couchbaseevents E/RemoteRequest﹕ io exception.  url: https://10.0.2.2:4984/ships/_local/74fbb4649e042fdae28537a02b680ad5890703e3
    javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
            at com.android.org.conscrypt.SSLNullSession.getPeerCertificates(SSLNullSession.java:104)
            at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:98)
            at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:393)
            at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:170)
            at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:169)
            at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:124)
            at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:365)
            at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:560)
            at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:492)
            at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:470)
            at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:184)
            at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:103)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)

URLを変更しようとするとhttp://10.0.2.2、次のようになります

08-23 09:23:33.012  20702-20702/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.couchbase.examples.couchbaseevents, PID: 20702
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.couchbase.examples.couchbaseevents/com.couchbase.examples.couchbaseevents.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Throwable.getMessage()' on a null object reference
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5257)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Throwable.getMessage()' on a null object reference
            at com.couchbase.examples.couchbaseevents.MainActivity.startReplications(MainActivity.java:139)
            at com.couchbase.examples.couchbaseevents.MainActivity.onCreate(MainActivity.java:56)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5257)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

同期ゲートウェイ コンソールを見ると、次のように表示されます。

2015-08-23T10:23:38.094+01:00 HTTP:  #001: GET /ships/_local/bfdf0950d51e390e054
bb31f2895d54b286c36a1
2015-08-23T10:23:38.095+01:00 HTTP: #001:     --> 404 missing  (1.0 ms)
2015-08-23T10:23:38.128+01:00 HTTP:  #002: POST /ships/_changes
2015-08-23T10:23:38.128+01:00 Changes: MultiChangesFeed({*}, {Since:0 Limit:0 Co
nflicts:true IncludeDocs:false Wait:false Continuous:false Terminator:0xc0820a92
c0 HeartbeatMs:300000 TimeoutMs:0}) ...
2015-08-23T10:23:38.129+01:00 Changes+: MultiChangesFeed: channels expand to cha
nnels.TimedSet{"!":0x1, "*":0x1} ...
2015-08-23T10:23:38.206+01:00 Changes+: MultiChangesFeed sending &{Seq:1 ID:_use
r/GUEST Deleted:false Removed:{} Doc:map[] Changes:[] Err:<nil> branched:false}

2015-08-23T10:23:38.207+01:00 Changes: MultiChangesFeed done
2015-08-23T10:23:38.229+01:00 HTTP:  #003: POST /ships/_changes
2015-08-23T10:23:38.230+01:00 Changes: MultiChangesFeed({*}, {Since:1 Limit:50 C
onflicts:true IncludeDocs:false Wait:true Continuous:false Terminator:0xc0822c21
80 HeartbeatMs:300000 TimeoutMs:0}) ...
2015-08-23T10:23:38.230+01:00 Changes+: MultiChangesFeed: channels expand to cha
nnels.TimedSet{"*":0x1, "!":0x1} ...
2015-08-23T10:23:38.230+01:00 Changes+: MultiChangesFeed waiting...
2015-08-23T10:23:38.230+01:00 Changes+: Waiting for "ships"'s count to pass 0

404 応答が返される理由がわかりません。ブラウザを使用して移動するhttp://127.0.0.1:4984/ships/_local/ee1ac8f4b732441355817ac7e9446c27e4089efbと、次の JSON 応答が返されます

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

データバケットはshipscouchbaseサーバーに確実に存在します

4

1 に答える 1

0

問題は、Couchbase Server の cbdocloader ツールを介してドキュメントを Couchbase に追加したことです。

同期を機能させるには、同期ゲートウェイ経由で追加する必要があります。同期ゲートウェイ REST API を介して一括読み込みを行いました

http://developer.couchbase.com/mobile/develop/references/sync-gateway/rest-api/database/post-bulk-docs/index.html

于 2015-08-28T09:08:31.077 に答える