Couchbase Lite.net 2.0 Replication to unknown host on Android

In my Xamarin Forms app on Android using CB Lite DB023:

When I replicate to an unresolvable hostname, I see that my ReplicationStatusChangeListener gets notified with state ‘Connecting’, but not with ‘Stopped’. Not sure if eventually it would go to state ‘Stopped’ on Android, but I didn’t see it within 60s.

The same situation in a UWP app gives me ‘Connecting’ followed by ‘Stopped’ and a CouchbaseException containg message “…No such host is known…”. That’s what I would expect on Android as well.

Could you have a look at the logs and see if it says anything about what exception is thrown, if any? I would expect the same behavior…but I am suspicious of any time things are run on Xamarin since there is another layer for things to go wrong. We haven’t run functional testing using Xamarin due to resource constraints as we focus on Windows based solutions (.NET Core / UWP).

@borrrden, I am hoping this helps:

.102662| [Sync]: (Replicator) [6] 2018-03-17T14:37:46.1025720+00:00 Replicator[< ws://hostname-doesnt-exist.es.XXXXX.int:4984/mdp-integration-test]: Starting
03-17 14:37:46.142 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.142 D/Mono    ( 5058): Searching for 'FLEncoder_New'.
03-17 14:37:46.143 D/Mono    ( 5058): Probing 'FLEncoder_New'.
03-17 14:37:46.143 D/Mono    ( 5058): Found as 'FLEncoder_New'.
03-17 14:37:46.143 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.143 D/Mono    ( 5058): Searching for 'FLEncoder_Finish'.
03-17 14:37:46.143 D/Mono    ( 5058): Probing 'FLEncoder_Finish'.
03-17 14:37:46.143 D/Mono    ( 5058): Found as 'FLEncoder_Finish'.
03-17 14:37:46.143 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.143 D/Mono    ( 5058): Searching for 'FLEncoder_Free'.
03-17 14:37:46.143 D/Mono    ( 5058): Probing 'FLEncoder_Free'.
03-17 14:37:46.143 D/Mono    ( 5058): Found as 'FLEncoder_Free'.
03-17 14:37:46.145 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.145 D/Mono    ( 5058): Searching for 'FLEncoder_WriteNull'.
23:36:16.171825| [DB]: Opening DataFile /data/user/0/XXXXX.YYYY.Tests.Android/files/Database/Cblc4v-GA/XXXXX.YYYY.Business.Database.Android.YYYYDatabaseDroid.cblite2/db.sqlite303-17 14:37:46.145 D/Mono    ( 5058): Probing 'FLEncoder_WriteNull'.

23:36:16.172640| [BLIP]: {N8litecore4blip10ConnectionE#5}==> N8litecore4blip10ConnectionE ->ws:hostname-doesnt-exist.es.XXXXX.int:4984/mdp-integration-test/_blipsync
23:36:16.172709| [BLIP]: {N8litecore4blip10ConnectionE#5} Opening connection...
23:36:16.172802| [Actor]: Starting Scheduler<0x83878100> with 2 threads03-17 14:37:46.145 D/Mono    ( 5058): Found as 'FLEncoder_WriteNull'.

23:36:16.173070| [Sync]: {Repl#6}==> N8litecore4repl10ReplicatorE /data/user/0/XXXXX.YYYY.Tests.Android/files/Database/Cblc4v-GA/XXXXX.YYYY.Business.Database.Android.YYYYDatabaseDroid.cblite2/ ->ws:hostname-doesnt-exist.es.XXXXX.int:4984/mdp-integration-test/_blipsync
23:36:16.173220| [Sync]: {Repl#6} Pull=one-shot, Options={"WS-Protocols":"BLIP_3+CBMobile_2",auth:{password:"XXXXX",type:"Basic",username:"XXXXXXXXXXXXXX"},headers:{"User-Agent":"CouchbaseLite/2.0.0 (.NET; Android 7.1.1 [API 25]; Google Android SDK built for x86) Build/636 LiteCore/732 Commit/f139283-c18ebea"}}03-17 14:37:46.147 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').

03-17 14:37:46.147 D/Mono    ( 5058): Searching for 'FLEncoder_EndDict'.
03-17 14:37:46.147 D/Mono    ( 5058): Probing 'FLEncoder_EndDict'.Thread started:  #8

03-17 14:37:46.147 D/Mono    ( 5058): Found as 'FLEncoder_EndDict'.
03-17 14:37:46.148 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.148 D/Mono    ( 5058): Searching for 'FLEncoder_BeginDict'.
03-17 14:37:46.148 D/Mono    ( 5058): Probing 'FLEncoder_BeginDict'.
03-17 14:37:46.148 D/Mono    ( 5058): Found as 'FLEncoder_BeginDict'.
03-17 14:37:46.150 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.150 D/Mono    ( 5058): Searching for 'FLEncoder_WriteKey'.
03-17 14:37:46.150 D/Mono    ( 5058): Probing 'FLEncoder_WriteKey'.
03-17 14:37:46.150 D/Mono    ( 5058): Found as 'FLEncoder_WriteKey'.
03-17 14:37:46.153 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.153 D/Mono    ( 5058): Searching for 'FLEncoder_WriteString'.
03-17 14:37:46.153 D/Mono    ( 5058): Probing 'FLEncoder_WriteString'.
03-17 14:37:46.153 D/Mono    ( 5058): Found as 'FLEncoder_WriteString'.
03-17 14:37:46.168 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.168 D/Mono    ( 5058): Searching for 'c4repl_getStatus'.
03-17 14:37:46.168 D/Mono    ( 5058): Probing 'c4repl_getStatus'.
03-17 14:37:46.168 D/Mono    ( 5058): Found as 'c4repl_getStatus'.
23:36:16.193021| [Sync]: (Replicator) [6] 2018-03-17T14:37:46.1928640+00:00 Replicator[< ws://hostname-doesnt-exist.es.XXXXX.int:4984/mdp-integration-test] is Connecting, progress 0/003-17 14:37:46.170 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').

03-17 14:37:46.170 D/Mono    ( 5058): Searching for 'c4repl_new'.
03-17 14:37:46.170 D/Mono    ( 5058): Probing 'c4repl_new'.
03-17 14:37:46.170 D/Mono    ( 5058): Found as 'c4repl_new'.23:36:16.196882| [Sync]: (Replicator) [6] 2018-03-17T14:37:46.1968130+00:00 Replicator[< ws://hostname-doesnt-exist.es.XXXXX.int:4984/mdp-integration-test] is Connecting, progress 0/0

03-17 14:37:46.189 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:46.189 D/Mono    ( 5058): Searching for 'c4socket_closed'.
03-17 14:37:46.189 D/Mono    ( 5058): Probing 'c4socket_closed'.
03-17 14:37:46.189 D/Mono    ( 5058): Found as 'c4socket_closed'.
Thread started:  #9
23:36:16.247722| [Sync]: {Repl#6} activityLevel=connecting: connectionState=1
Thread started:  #10
Thread finished:  #9
The thread 0x9 has exited with code 0 (0x0).
03-17 14:37:49.062 D/Mono    ( 5058): Unloading image System.Linq.dll [0xad8deb00].
03-17 14:37:49.062 D/Mono    ( 5058): Image addref System.Linq[0xad8860e0] -> System.Linq.dll[0x8766f500]: 16
03-17 14:37:49.062 D/Mono    ( 5058): Config attempting to parse: 'System.Linq.dll.config'.
03-17 14:37:49.062 D/Mono    ( 5058): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Linq/System.Linq.config'.
03-17 14:37:49.062 D/Mono    ( 5058): Assembly Ref addref XXXXX.YYYY.Shared[0x9f953280] -> System.Linq[0x88319a20]: 14
03-17 14:37:56.473 I/        ( 5058): [Information] Stopping Testcase XXXXX.YYYY.Tests.Android.Business.Database.ReplicationTestsDroid.ReplicationBasicAuthBadHostname
03-17 14:37:56.488 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:56.488 D/Mono    ( 5058): Searching for 'c4error_make'.
03-17 14:37:56.488 D/Mono    ( 5058): Probing 'c4error_make'.
03-17 14:37:56.488 D/Mono    ( 5058): Found as 'c4error_make'.
03-17 14:37:56.503 D/Mono    ( 5058): DllImport searching in: 'LiteCore' ('libLiteCore.so').
03-17 14:37:56.503 D/Mono    ( 5058): Searching for 'c4error_getMessage'.
03-17 14:37:56.503 D/Mono    ( 5058): Probing 'c4error_getMessage'.
03-17 14:37:56.503 D/Mono    ( 5058): Found as 'c4error_getMessage'.
[0:] Binding: 'TestResult' property not found on 'NUnit.Runner.Helpers.ResultSummary', target property: 'Xamarin.Forms.Label.Text'
[0:] Binding: 'TestResult' property not found on 'NUnit.Runner.Helpers.ResultSummary', target property: 'Xamarin.Forms.Label.Text'
[0:] Binding: 'TestResult' property not found on 'NUnit.Runner.Helpers.ResultSummary', target property: 'Xamarin.Forms.Label.Text'
03-17 14:38:23.617 W/AppCenter( 5058): Try #1 failed and will be retried in 7903 ms (UnknownHostException)
03-17 14:38:23.617 W/AppCenter( 5058): Try #1 failed and will be retried in 6069 ms (UnknownHostException)
23:36:56.395743| [Couchbase] WARNING: (SerialQueue) [11] 2018-03-17T14:38:26.3900060+00:00 Exception during DispatchAsync: System.Net.Sockets.SocketException (0x80004005): Could not resolve host 'hostname-doesnt-exist.es.XXXXX.int'
  at System.Net.Dns.Error_11001 (System.String hostName) [0x00015] in <bcdc1df2b3724ab69797f3819a126346>:0 
  at System.Net.Dns.GetHostByName (System.String hostName) [0x00021] in <bcdc1df2b3724ab69797f3819a126346>:0 
  at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00052] in <bcdc1df2b3724ab69797f3819a126346>:0 
  at System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress) [0x00056] in <bcdc1df2b3724ab69797f3819a126346>:0 
  at System.Net.Sockets.Socket.BeginConnect (System.String host, System.Int32 port, System.AsyncCallback requestCallback, System.Object state) [0x0005c] in <bcdc1df2b3724ab69797f3819a126346>:0 
  at System.Net.Sockets.TcpClient.BeginConnect (System.String host, System.Int32 port, System.AsyncCallback requestCallback, System.Obje
ct state) [0x0000c] in <bcdc1df2b3724ab69797f3819a126346>:0 
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncImpl[TArg1,TArg2] (System.Func`5[T1,T2,T3,T4,TResult] beginMethod, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, TArg1 arg1, TArg2 arg2, System.Object state, System.Threading.Tasks.TaskCreationOptions creationOptions) [0x00170] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 
  at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2] (System.Func`5[T1,T2,T3,T4,TResult] beginMethod, System.Action`1[T] endMethod, TArg1 arg1, TArg2 arg2, System.Object state, System.Threading.Tasks.TaskCreationOptions creationOptions) [0x00000] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 
  at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2] (System.Func`5[T1,T2,T3,T4,TResult] beginMethod, System.Action`1[T] endMethod, TArg1 arg1, TArg2 arg2, System.Object state) [0x00000] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 
  at System.Net.Sockets.TcpClient.ConnectAsync (System.String host, System.I
nt32 port) [0x00005] in <bcdc1df2b3724ab69797f3819a126346>:0 
  at Couchbase.Lite.Sync.WebSocketWrapper.<Start>b__24_0 () [0x000fd] in C:\Jenkins\workspace\couchbase-lite-net-edition-build\couchbase-lite-net-ee\couchbase-lite-net\src\Couchbase.Lite.Shared\Sync\WebSocketWrapper.cs:201 
  at Couchbase.Lite.Support.SerialQueue.ProcessAsync () [0x0002f] in C:\Jenkins\workspace\couchbase-lite-net-edition-build\couchbase-lite-net-ee\couchbase-lite-net\src\Couchbase.Lite.Shared\Support\SerialQueue.cs:175 
Thread finished:  #10
The thread 0xa has exited with code 0 (0x0).
03-17 14:38:33.628 W/AppCenter( 5058): Try #1 failed and will be retried in 7688 ms (UnknownHostException)
03-17 14:38:33.629 W/AppCenter( 5058): Try #2 failed and will be retried in 260352 ms (UnknownHostException)
Thread finished: <Thread Pool> #3
Thread started: <Thread Pool> #11
The thread 0x3 has exited with code 0 (0x0).

Yes, I can confirm that the Replicator never gets out of “Connecting” state when attempting to connect to unreachable host.

  • On Xamarin Android : No exceptions throws (At least nothing obvious) . See logs
  • On Xamarin iOS : An exception is thrown but replicator continues to be in Connecting state . See logs

@borrrden : Ticket filed in GitHub … reproducible using our Travel Sample App