LiteC issue on Windows: non-blocking socket operation error

Hello,

I am receiving the following error when attempting to begin replication. I am compiling couchbase-lite-C from the master branch using CMake.

This happens only when compiled and ran on Windows 10 – compiling and running the same code (and connecting to the same Websocket endpoint) on MacOS works just fine, no problems w/ database replication.

Any help is appreciated. Thanks in advance.

16:55:50.087897| [Sync]: {Repl#22}==> class litecore::repl::Replicator C:\Users\xxxxx\Desktop\xxxxx.cblite2\ ->xxxxx:443/xxxxx/_blipsync @000001F74D4AD58816:55:50.088468| [Sync]: {Repl#22} Pull=continuous, Options={{}}
16:55:50.088659| [Sync]: {C4Replicator#23}==> class c4Internal::C4RemoteReplicator 000001F74D194250 @000001F74D194250
16:55:50.088876| [Sync]: {C4Replicator#23} Starting Replicator {Repl#22}
16:55:50.090899| [Sync]: {Repl#22} No local checkpoint ‘cp-2HRgYvzLOR9Sn1mQNvgNj1iyDhs=’
16:55:50.183987| [WS] WARNING: ClientSocket got POSIX error 140 "A non-blocking socket operation could not be completed immediately.
"
16:55:50.184435| [WS]: {BuiltInWebSocket#24}==> class litecore::websocket::BuiltInWebSocket xxxxx:443/xxxxx-x/_blipsync @000001F74D2F35C0
16:55:50.184781| [WS] WARNING: {BuiltInWebSocket#24} Unexpected or unclean socket disconnect! (reason=Network error, code=3)
16:55:50.185010| [Sync]: {Repl#22} Connection closed with Network error 3: “connection timed out” (state=1)16:55:50.185392| [Sync] ERROR: {Repl#22} Got LiteCore error: Network error 3 “connection timed out”

I’m guessing the error 140 is EWOULDBLOCK / EAGAIN, which we should be ignoring. Any idea, @borrrden?

@victorberger, would you mind trying the dev branch of couchbase-lite-c? It’s using a somewhat newer revision of couchbase-lite-core, which may have Windows-specific fixes. Let me know if it works any differently. Thanks.

@jens Thank you for your reply.

Using the “dev” branch:

  1. On MacOS, it caused SSL replications to only partially work (were working fine before). It seems that some of the contents are transferred but then the replications stops. These are the messages when it happens:

12:27:44.264699| [DB]: {DB#169} Opening database
12:27:44.267754| [Sync]: {Inserter#170}==> litecore::repl::Inserter ->wss://xxx.com:443/xxx-xxx/_blipsync @0x7ff8446605d8
12:27:44.267775| [Sync]: {Inserter#170} Inserted 9 revs in 3.20ms ( 2813/sec) of which 99.7% was commit
TLS: >>> BIO returning MBEDTLS_ERR_SSL_WANT_READ
TLS: >>> mbedtls_socket returning EWOULDBLOCK
12:27:44.330856| [WS]: {BuiltInWebSocket#171}==> litecore::websocket::BuiltInWebSocket wss://xxx-xxxx.com:443/xxxx/_blipsync @0x7ff84465f5f0
12:27:44.330906| [WS] WARNING: {BuiltInWebSocket#171} Unexpected or unclean socket disconnect! (reason=errno, code=0)
12:27:44.330989| [Sync]: {Repl#161} Connection closed with WebSocket status 1006: “” (state=2)
12:27:44.331069| [Sync] ERROR: {Repl#161} Got LiteCore error: WebSocket error 1006 “connection closed abnormally”

  1. On Windows, it seems to work correctly with “WS” endpoints, but not “WSS”. With WSS, I see the following message:

12:32:34.837887| [Sync]: {C4Replicator#87} Starting Replicator {Repl#86}
12:32:34.839104| [Sync]: {Repl#86} Scanning for pre-existing conflicts…
12:32:34.839239| [Sync]: {Repl#86} Found 0 conflicted docs in 0.001 sec
12:32:34.839834| [Sync]: {Repl#86} No local checkpoint ‘cp-iw9MseqhhVgzw1GeCMKoq+8UC48=’
12:32:35.063827| [WS] ERROR: mbedTLS©: x509_verify_cert() returned -9984 (-0x2700)
TLS: mbedtls error -0x2700 from mbedtls_ssl_handshake: X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
12:32:35.064661| [WS] ERROR: TCPSocket TLS handshake failed; cert verify status 0x08
12:32:35.064853| [WS]: {BuiltInWebSocket#88}==> class litecore::websocket::BuiltInWebSocket wss://x-xxxx.com:443/xxx/_blipsync @0000015D06ED3C00
12:32:35.065248| [WS] WARNING: {BuiltInWebSocket#88} Unexpected or unclean socket disconnect! (reason=Network error, code=11)
12:32:35.065671| [Sync]: {Repl#86} Connection closed with Network error 11: “The certificate is not correctly signed by the trusted CA” (state=1)
12:32:35.066091| [Sync] ERROR: {Repl#86} Got LiteCore error: Network error 11 “The certificate is not correctly signed by the trusted CA”

Hello, are there any updates on this ?

Well on Windows the error seems pretty straightforward. We don’t have a lot of time at the moment to spend on C so it will probably be a good amount of time before this gets addressed, assuming we can replicate it.