couchbaselabs / mobile-training-todo

ToDo List app built with Couchbase Mobile
57 stars 38 forks source link

Uri scheme is error #178

Closed loongsun closed 6 years ago

loongsun commented 6 years ago

// ------------------------- // Replicator operation // ------------------------- private void startReplication(String username, String password) { if (!SYNC_ENABLED) return;

    URI uri;
    Endpoint endpoint;
    try {
        uri = new URI(SYNCGATEWAY_URL);
        boolean secure = uri.getScheme().endsWith("s");
        **_endpoint = new URLEndpoint(uri.getHost(),uri.getPort(), uri.getPath(), secure);_**
    } catch (URISyntaxException e) {
        Log.e(TAG, "Failed parse URI: %s", e, SYNCGATEWAY_URL);
        return;
    }
hideki commented 6 years ago

@loongsun which commit are you using of mobile-training-todo repo?

loongsun commented 6 years ago

your latest commits on Jan 27, 2018.:)

loongsun commented 6 years ago

Constructor with the url is URLEndpoint(URI url) in the lib db2.0.0-291, but the constructor is URLEndpoint(uri.getHost(),uri.getPort(), uri.getPath(), secure) in the demo code. Uri scheme is "ws" or"wss" in the lib db2.0.0-291,but scheme is "blip" in the demo code!

hideki commented 6 years ago

@loongsun Thanks again for bug report!

loongsun commented 6 years ago

In the CBD lib the scheme is: //--------------------------------------------- // Constant variables //--------------------------------------------- private static final String kURLEndpointScheme = "ws"; private static final String kURLEndpointTLSScheme = "wss"; public URLEndpoint(URI url) { if (url == null) { throw new IllegalArgumentException("The url parameter cannot be null."); }

    String scheme = url.getScheme();
    if (!(kURLEndpointScheme.equals(scheme) || kURLEndpointTLSScheme.equals(scheme))) {
        throw new IllegalArgumentException(
                "The url parameter has an unsupported URL scheme (" + scheme + ") " +
                "The supported URL schemes are " + kURLEndpointScheme + " and " + kURLEndpointTLSScheme + ".");
    }

    this.url = url;
}

but in the demo code,the scheme is :: private final static String SYNCGATEWAY_URL = "blip://10.0.2.2:4984/todo/";

that will throw "new IllegalArgumentException"!

loongsun commented 6 years ago

@hideki

hideki commented 6 years ago

@loongsun Thank you again!

loongsun commented 6 years ago

@hideki hi,hideki: i use the latest demo, the error occurs ::

1-29 15:12:41.216 21051-21111/com.couchbase.todo E/LiteCore [BLIP]: {N8litecore4blip6BLIPIOE#2}==> N8litecore4blip6BLIPIOE ->ws:192.168.2.166:4984/todo/_blipsync
01-29 15:12:41.216 21051-21111/com.couchbase.todo E/LiteCore [BLIP]: {N8litecore4blip6BLIPIOE#2} Caught exception handling incoming BLIP message: BLIP message invalid checksum
01-29 15:12:41.217 21051-21111/com.couchbase.todo E/C4Socket: C4Socket.callback.requestClose() socket -> 0x7bb6a66818, status -> 1006, message -> BLIP message invalid checksum
01-29 15:12:41.217 21051-21111/com.couchbase.todo E/AndroidRuntime: FATAL EXCEPTION: Thread-7
                                                                    Process: com.couchbase.todo, PID: 21051
                                                                    java.lang.IllegalArgumentException: Code 1006 is reserved and may not be used.
                                                                        at okhttp3.internal.ws.WebSocketProtocol.validateCloseCode(WebSocketProtocol.java:120)
                                                                        at okhttp3.internal.ws.RealWebSocket.close(RealWebSocket.java:401)
                                                                        at okhttp3.internal.ws.RealWebSocket.close(RealWebSocket.java:397)
                                                                        at com.couchbase.lite.internal.replicator.CBLWebSocket.requestClose(CBLWebSocket.java:226)
loongsun commented 6 years ago

i use the sync-gateway-config.json in the objc :: { "interface":":4984", "log": ["*"], "databases": { "todo": { "server": "walrus:", "users": { "user1": {"password": "pass", "admin_channels": ["user1"]}, "user2": {"password": "pass", "admin_channels": ["user2"]}, "user3": {"password": "pass", "admin_channels": ["user3"]}, "mod": {"password": "pass", "admin_roles": ["moderator"]}, "admin": {"password": "pass", "admin_roles": ["admin"]} }, "roles": { "moderator": {}, "admin": {} }, "unsupported": { "replicator_2":true }, "sync": ` function(doc, oldDoc){'.........

hideki commented 6 years ago

Hi @loongsun, Are you using latest Sync Gateway build? The recent build includes the support of compression with BLIP protocol. You could download Sync Gateway build from the following link. http://latestbuilds.service.couchbase.com/builds/latestbuilds/sync_gateway/2.0.0/ Thanks, Hideki

hideki commented 6 years ago

From SG 2.0.0

You can remove followng lines from configuration file.

"unsupported": {
"replicator_2":true
},
hideki commented 6 years ago

@loongsun FYI: It seems latestbuilds.service.couchbase.com is down now or it is not accessible from the public network.

loongsun commented 6 years ago

@hideki, thanks to you, i wait for some days! it is not accessible from the public network now.

loongsun commented 6 years ago

@hideki ,hi hideki, http://latestbuilds.service.couchbase.com/builds/latestbuilds/sync_gateway/2.0.0/ is not down now. can you down one to me?my email is 125736964@qq.com.

hideki commented 6 years ago

@loongsun, The company might intentionally make it not accessible from public IP. Could you please wait for the next SG release? Thanks!

loongsun commented 6 years ago

@hideki ,There is no other way, so i only have to wait for it released. By the way,when is the next SG released?when is the couchbase lite db022 released? Thanks!

hideki commented 6 years ago

We planned to release it earlier. But we have been facing delay. Thank you for your patience!

loongsun commented 6 years ago

ok, thanks,look forward to your good news!