Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-1495

Replicator is stuck in "connecting" state: Root cause

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.8.1
    • Fix Version/s: 2.8.4
    • Component/s: Java-Android, Java-Desktop
    • Security Level: Public
    • Labels:
      None
    • Sprint:
      Blake 36, Blake 37
    • Story Points:
      3

      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.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

            Hide
            blake.meike Blake Meike added a comment -

            fixed in couchbase-lite-java-common @ d2413f29730b1d9a4544244f

            Show
            blake.meike Blake Meike added a comment - fixed in couchbase-lite-java-common @ d2413f29730b1d9a4544244f
            Hide
            blake.meike Blake Meike added a comment -

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

            Show
            blake.meike Blake Meike added a comment - Re-open these issues until they are fixed in the hydrogen branch, for 2.8.x
            Hide
            blake.meike Blake Meike added a comment -

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

            Show
            blake.meike Blake Meike added a comment - Fixed in couchbase-lite-java-common @ 10c53746c3fae9a19d6aaf6d

              People

              Assignee:
              blake.meike Blake Meike
              Reporter:
              blake.meike Blake Meike
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes

                    PagerDuty