Replicator is stuck in "connecting" state: Root cause

Description

Copied from https://github.com/couchbase/couchbase-lite-java-ce-root/issues/13 :

A AbstractCBLWebSocket object is constructed with webSocket member var to be null, and it is not set until onOpen event listener is called when websocket handshake finishes (after the tcp connection establishes).
Couchbase lite core handles connection timeout (with a default value of 15), and it will eventually call AbstractCBLWebSocket.requestClose method to close it on timeout is detected.
Look at first several lines of this method, AbstractCBLWebSocket.requestClose, there's a shortcut return if webSocket is null, which is true when connection timeout happens. Okhttp know nothing about the request to close, it will keep trying (and retry) to connect.
And okhttp timeouts are explicitly set to 0 (because core would take charge), so it hangs for a very long time, maybe forever, even if the bad network recovers. Replicator is stuck in "connecting" state if we check from outside (sometimes "busy").
okhttp sometimes decides to stop and raise an exception in time, luckily, onFailure is called and end all this. (So we can know the failure from outside and restart replication)
There's another possibility that handshake finally succeeds after the core decide to close it because of timeout. I'm not sure what will happen then.

Activity

Show:

Blake Meike January 11, 2021 at 11:37 PM

Fixed in couchbase-lite-java-common @ 10c53746c3fae9a19d6aaf6d

Blake Meike January 11, 2021 at 11:02 PM

Re-open these issues until they are fixed in the hydrogen branch, for 2.8.x

Blake Meike January 6, 2021 at 7:02 PM

fixed in couchbase-lite-java-common @ d2413f29730b1d9a4544244f

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Sprint

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created December 10, 2020 at 1:19 AM
Updated February 3, 2021 at 12:32 AM
Resolved January 11, 2021 at 11:37 PM
Instabug