Couchbase-lite-C replication not working on WIndows

The replication on windows is always offline showing this Couchbase error:
ClientSocket got POSIX error 140 "A non-blocking socket operation could not be completed immediately.

I looked into the the ssize_t TCPSocket::_read(void *dst, size_t byteCount), there seems to be an inconsistency there between the comment and the functionality, namely between" Assumes EWOULDBLOCK is not an error" and checkStreamError which checks for that error. However skipping the error in that case did not solve the issue(it then gets to “Unexpected or unclean socket disconnect!”)

I tried to run the tests to see if I can isolate the problem in a testcase, but I couldn’t run them, apparently some file names have changed (for example slice.cc to sliceIO.cc) but not in the tests cmake(I tried to fix those names but it wasn’t enough).

I’m posting below the logs without any change in the Couchbase library from my side. In those logs I’m opening the database and creating several queries, then I try to replicate the database.:

{DB#1} Opening database

Seeding the mbedTLS random number generator...

{CollectionImpl#2} Instantiated

{Query#3} Compiling N1QL query: SELECT * FROM _ WHERE type='query_A'

{Query#3} Compiled as SELECT fl_result(fl_root(_.body)) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_A') AND (_.flags & 1 = 0)

Starting Scheduler<000001432CA85D20> with 8 threads

{DB#4} Opening database

{LiveQuerier#5} Created on Query {Query#3}

{Query#6} Compiling N1QL query: SELECT meta().id FROM _ WHERE type='query_A'

{Query#7} Compiling N1QL query: SELECT * FROM _ WHERE type='query_A'

{Query#6} Compiled as SELECT fl_result(_.key) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_A') AND (_.flags & 1 = 0)

{Query#7} Compiled as SELECT fl_result(fl_root(_.body)) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_A') AND (_.flags & 1 = 0)

{Query#8} Compiling N1QL query: SELECT * FROM _ WHERE type='query_B'

{QueryEnum#9} Created on {Query#7} with 0 rows (2 bytes) in 0.214ms

{LiveQuerier#5} Results changed at seq 0 (8.428ms)

{Query#8} Compiled as SELECT fl_result(fl_root(_.body)) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_B') AND (_.flags & 1 = 0)

{LiveQuerier#10} Created on Query {Query#8}

{Query#11} Compiling N1QL query: SELECT * FROM _ WHERE type='query_B'

{Query#12} Compiling N1QL query: SELECT meta().id FROM _ WHERE type='query_B'

{Query#11} Compiled as SELECT fl_result(fl_root(_.body)) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_B') AND (_.flags & 1 = 0)

{Query#12} Compiled as SELECT fl_result(_.key) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_B') AND (_.flags & 1 = 0)

{QueryEnum#13} Created on {Query#11} with 0 rows (2 bytes) in 0.158ms

{LiveQuerier#10} Results changed at seq 0 (19.207ms)

{Query#14} Compiling N1QL query: SELECT * FROM _ WHERE type='query_C'

{Query#14} Compiled as SELECT fl_result(fl_root(_.body)) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_C') AND (_.flags & 1 = 0)

{LiveQuerier#15} Created on Query {Query#14}

{Query#16} Compiling N1QL query: SELECT * FROM _ WHERE type='query_C'

{Query#17} Compiling N1QL query: SELECT meta().id FROM _ WHERE type='query_C'

{Query#16} Compiled as SELECT fl_result(fl_root(_.body)) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_C') AND (_.flags & 1 = 0)

{Query#17} Compiled as SELECT fl_result(_.key) FROM kv_default AS _ WHERE (fl_value(_.body, 'type') = 'query_C') AND (_.flags & 1 = 0)

Created [SELECT meta().id FROM _ WHERE type='query_C'] query.

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_A"]}

{QueryEnum#19} Created on {Query#6} with 0 rows (2 bytes) in 0.143ms

{QueryEnum#19} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_C"]}

{QueryEnum#20} Created on {Query#17} with 0 rows (2 bytes) in 0.145ms

{QueryEnum#20} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["."]],"WHERE":["=",[".type"],"query_B"]}

{QueryEnum#21} Created on {Query#8} with 0 rows (2 bytes) in 0.058ms

{QueryEnum#21} Deleted

{DB#22} Opening database

{CollectionImpl#23} Instantiated

{Repl#24} Pull=continuous, Options={{auth:{password:"********", type:"Basic", username:"username"}}}

{C4Replicator#25} Starting Replicator {Repl#24}

{Repl#24} Scanning for pre-existing conflicts...

{Repl#24} Found 0 conflicted docs in 0.040 sec

{Repl#24} Ignoring local checkpoint ('reset' option is set)

{Repl#24} Connected!

{Repl#24} now busy

{C4Replicator#25} State: busy, progress=0.00%

CBLReplicator status: busy, progress=0/0, flag=2, error=0/0 (effective status=busy, completed=0.00%, docs=0)

{Puller#26} Starting pull from remote seq ''

{Puller#26} msg["revocations"]="true" due to enableAutoPurge()=1 or progressNotificationLevel()=0 > 0

{Repl#24} No remote checkpoint 'cp-juRwAsK9OZdFhN4GW7x1fQQRfbI='

ClientSocket got POSIX error 140 "A non-blocking socket operation could not be completed immediately.

"

{BuiltInWebSocket#27} Unexpected or unclean socket disconnect! (reason=Network error 3)

{Repl#24} Connection closed with Network error 3: "connection timed out" (state=2)

{Repl#24} Got LiteCore error: Network error 3, "connection timed out"

{C4Replicator#25} State: busy, progress=0.00%, error=Network error 3, "connection timed out"

CBLReplicator status: busy, progress=0/0, flag=2, error=5/3 (effective status=busy, completed=0.00%, docs=0)

{Repl#24} now stopped

BLIP sent 2 msgs (158 bytes), rcvd 0 msgs (54 bytes) in 0.335 sec. Max outbox depth was 1, avg 1.00

{CollectionImpl#23} Closed

{DB#22} Closing database

{C4Replicator#25} Transient error (Network error 3, "connection timed out"); attempt #2 in 2 sec...

{C4Replicator#25} State: offline, progress=0.00%, error=Network error 3, "connection timed out"

CBLReplicator status: offline, progress=0/0, flag=3, error=5/3 (effective status=offline, completed=0.00%, docs=0)

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_A"]}

{QueryEnum#28} Created on {Query#6} with 0 rows (2 bytes) in 0.349ms

{QueryEnum#28} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_C"]}

{QueryEnum#29} Created on {Query#17} with 0 rows (2 bytes) in 0.242ms

{QueryEnum#29} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["."]],"WHERE":["=",[".type"],"query_B"]}

{QueryEnum#30} Created on {Query#8} with 0 rows (2 bytes) in 0.187ms

{QueryEnum#30} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_A"]}

{QueryEnum#31} Created on {Query#6} with 0 rows (2 bytes) in 0.066ms

{QueryEnum#31} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_C"]}

{QueryEnum#32} Created on {Query#17} with 0 rows (2 bytes) in 0.046ms

{QueryEnum#32} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["."]],"WHERE":["=",[".type"],"query_B"]}

{QueryEnum#33} Created on {Query#8} with 0 rows (2 bytes) in 0.070ms

{QueryEnum#33} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_A"]}

{QueryEnum#34} Created on {Query#6} with 0 rows (2 bytes) in 0.142ms

{QueryEnum#34} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_C"]}

{QueryEnum#35} Created on {Query#17} with 0 rows (2 bytes) in 0.070ms

{QueryEnum#35} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["."]],"WHERE":["=",[".type"],"query_B"]}

{QueryEnum#36} Created on {Query#8} with 0 rows (2 bytes) in 0.068ms

{QueryEnum#36} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_A"]}

{QueryEnum#37} Created on {Query#6} with 0 rows (2 bytes) in 0.059ms

{QueryEnum#37} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["_.",["meta()"],".id"]],"WHERE":["=",[".type"],"query_C"]}

{QueryEnum#38} Created on {Query#17} with 0 rows (2 bytes) in 0.095ms

{QueryEnum#38} Deleted

2|0|0| SCAN TABLE kv_default AS _

{"FROM":[{"COLLECTION":"_"}],"WHAT":[["."]],"WHERE":["=",[".type"],"query_B"]}

{QueryEnum#39} Created on {Query#8} with 0 rows (2 bytes) in 11.741ms

{QueryEnum#39} Deleted

{C4Replicator#25} Retrying connection to wss://concepts-test.tophatch.com:443/db/_blipsync (attempt #2)...

{DB#40} Opening database

{CollectionImpl#41} Instantiated

{Repl#42} Pull=continuous, Options={{auth:{password:"********", type:"Basic", username:"username"}}}

{C4Replicator#25} Starting Replicator {Repl#42}

{Repl#42} Scanning for pre-existing conflicts...

{Repl#42} Found 0 conflicted docs in 0.003 sec

{Repl#42} No local checkpoint 'cp-juRwAsK9OZdFhN4GW7x1fQQRfbI='

{Repl#42} Connected!

{Repl#42} now busy

{C4Replicator#25} State: busy, progress=0.00%

CBLReplicator status: busy, progress=0/0, flag=2, error=0/0 (effective status=busy, completed=0.00%, docs=0)

{Puller#43} Starting pull from remote seq ''

{Puller#43} msg["revocations"]="true" due to enableAutoPurge()=1 or progressNotificationLevel()=0 > 0

{Repl#42} No remote checkpoint 'cp-juRwAsK9OZdFhN4GW7x1fQQRfbI='

ClientSocket got POSIX error 140 "A non-blocking socket operation could not be completed immediately.

"

{BuiltInWebSocket#44} Unexpected or unclean socket disconnect! (reason=Network error 3)

{Repl#42} Connection closed with Network error 3: "connection timed out" (state=2)

{Repl#42} Got LiteCore error: Network error 3, "connection timed out"

{C4Replicator#25} State: busy, progress=0.00%, error=Network error 3, "connection timed out"

CBLReplicator status: busy, progress=0/0, flag=2, error=5/3 (effective status=busy, completed=0.00%, docs=0)

{Repl#42} now stopped

BLIP sent 2 msgs (174 bytes), rcvd 0 msgs (54 bytes) in 0.395 sec. Max outbox depth was 1, avg 1.00

{CollectionImpl#41} Closed

{DB#40} Closing database

{C4Replicator#25} Transient error (Network error 3, "connection timed out"); attempt #2 in 2 sec...

{C4Replicator#25} State: offline, progress=0.00%, error=Network error 3, "connection timed out"

CBLReplicator status: offline, progress=0/0, flag=3, error=5/3 (effective status=offline, completed=0.00%, docs=0)

{C4Replicator#25} Retrying connection to wss://concepts-test.tophatch.com:443/db/_blipsync (attempt #2)...

{DB#45} Opening database

{CollectionImpl#46} Instantiated

{Repl#47} Pull=continuous, Options={{auth:{password:"********", type:"Basic", username:"username"}}}

{C4Replicator#25} Starting Replicator {Repl#47}

{Repl#47} Scanning for pre-existing conflicts...

{Repl#47} Found 0 conflicted docs in 0.003 sec

{Repl#47} No local checkpoint 'cp-juRwAsK9OZdFhN4GW7x1fQQRfbI='

{Repl#47} Connected!

{Repl#47} now busy

{C4Replicator#25} State: busy, progress=0.00%

CBLReplicator status: busy, progress=0/0, flag=2, error=0/0 (effective status=busy, completed=0.00%, docs=0)

{Puller#48} Starting pull from remote seq ''

{Puller#48} msg["revocations"]="true" due to enableAutoPurge()=1 or progressNotificationLevel()=0 > 0

{Repl#47} No remote checkpoint 'cp-juRwAsK9OZdFhN4GW7x1fQQRfbI='

ClientSocket got POSIX error 140 "A non-blocking socket operation could not be completed immediately.

"

{BuiltInWebSocket#49} Unexpected or unclean socket disconnect! (reason=Network error 3)

{Repl#47} Connection closed with Network error 3: "connection timed out" (state=2)

{Repl#47} Got LiteCore error: Network error 3, "connection timed out"

{C4Replicator#25} State: busy, progress=0.00%, error=Network error 3, "connection timed out"

CBLReplicator status: busy, progress=0/0, flag=2, error=5/3 (effective status=busy, completed=0.00%, docs=0)

{Repl#47} now stopped

BLIP sent 2 msgs (174 bytes), rcvd 0 msgs (54 bytes) in 0.362 sec. Max outbox depth was 1, avg 1.00

{CollectionImpl#46} Closed

{DB#45} Closing database

{C4Replicator#25} Transient error (Network error 3, "connection timed out"); attempt #2 in 2 sec...

{C4Replicator#25} State: offline, progress=0.00%, error=Network error 3, "connection timed out"

CBLReplicator status: offline, progress=0/0, flag=3, error=5/3 (effective status=offline, completed=0.00%, docs=0)

Is it possible to enable verbose log and share a complete log? From the above log, I couldn’t see anything beside query log.

Also could you try the beta version of CBL-C available on couchbase.com website and see if you still see the issue?