Android not connecting to sync gateway because of some socket error

I’m having a hard time getting android to connect to sync gateway. Apparently it never manages to establish a connection.
The same code with the same sync gateway runs fine in UWP, by the way.
There is an error in the log messages on the client side dealing with SocketOptions (see below) which might be responsible?
Sync Gateway doesn’t give any indication of being connected to in its messages.
Any ideas? Any help is highly appreciated!

Here is the log extract:
07-30 20:05:51.843 I/CouchbaseLite(19049): [1] 2017-7-30 08:05:51.856+02:00 SYNC (Replicator) [1] 2017-07-30T20:05:51.8561700+02:00 Replicator[<> ws://localhost:4984/db]: Starting
07-30 20:05:51.853 I/CouchbaseLite(19049): [1] 2017-7-30 08:05:51.857+02:00 DB (DB) [1] 2017-07-30T20:05:51.8576430+02:00 Opening DataFile /data/data/meeapp.Droid/files/.local/share/db.cblite2/db.sqlite3
07-30 20:05:51.853 I/CouchbaseLite(19049): [1] 2017-7-30 08:05:51.861+02:00 LITECORE (BLIP) [1] 2017-07-30T20:05:51.8609230+02:00 {2}–> ->ws:localhost:4984/db/_blipsync
07-30 20:05:51.853 I/CouchbaseLite(19049): [1] 2017-7-30 08:05:51.862+02:00 LITECORE (BLIP) [1] 2017-07-30T20:05:51.8621520+02:00 {2} Opening connection…
Thread started: #11
07-30 20:05:51.863 I/CouchbaseLite(19049): [13] 2017-7-30 08:05:51.871+02:00 LITECORE (Actor) [13] 2017-07-30T20:05:51.8710030+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
07-30 20:05:51.863 I/CouchbaseLite(19049): [5] 2017-7-30 08:05:51.872+02:00 LITECORE (Actor) [5] 2017-07-30T20:05:51.8718810+02:00 Repl->ws:localhost:4984/db/_blipsync performNextMessage
07-30 20:05:51.863 I/CouchbaseLite(19049): [1] 2017-7-30 08:05:51.871+02:00 SYNC (Replicator) [1] 2017-07-30T20:05:51.8711650+02:00 Replicator[<
> ws://localhost:4984/db] is Connecting, progress 0/0
07-30 20:05:51.863 I/CouchbaseLite(19049): [4] 2017-7-30 08:05:51.873+02:00 LITECORE (Actor) [4] 2017-07-30T20:05:51.8732430+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
07-30 20:05:51.863 I/CouchbaseLite(19049): [4] 2017-7-30 08:05:51.874+02:00 LITECORE (Actor) [4] 2017-07-30T20:05:51.8741870+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
07-30 20:05:51.863 I/CouchbaseLite(19049): [4] 2017-7-30 08:05:51.875+02:00 LITECORE (Actor) [4] 2017-07-30T20:05:51.8749840+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
07-30 20:05:51.863 I/CouchbaseLite(19049): [6] 2017-7-30 08:05:51.876+02:00 LITECORE (Actor) [6] 2017-07-30T20:05:51.8757590+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
07-30 20:05:51.863 I/CouchbaseLite(19049): [6] 2017-7-30 08:05:51.876+02:00 LITECORE (Actor) [6] 2017-07-30T20:05:51.8765140+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
07-30 20:05:51.873 I/CouchbaseLite(19049): [6] 2017-7-30 08:05:51.877+02:00 LITECORE (Actor) [6] 2017-07-30T20:05:51.8772590+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
07-30 20:05:51.873 I/CouchbaseLite(19049): [13] 2017-7-30 08:05:51.878+02:00 LITECORE (Actor) [13] 2017-07-30T20:05:51.8780850+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
Thread started: #12
07-30 20:05:51.873 I/CouchbaseLite(19049): [13] 2017-7-30 08:05:51.879+02:00 LITECORE (Actor) [13] 2017-07-30T20:05:51.8788320+02:00 BLIP[->ws:localhost:4984/db/_blipsync] performNextMessage
Thread started: #13
Thread finished: #12
07-30 20:05:51.883 W/CouchbaseLite(19049): [15] 2017-7-30 08:05:51.896+02:00 TASK SCHEDULING (SerialQueue) [15] 2017-07-30T20:05:51.8937400+02:00 Exception during DispatchAsync: System.ArgumentException: Value does not fall within the expected range.
07-30 20:05:51.883 W/CouchbaseLite(19049): at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) [0x00029] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/System/System.Net.Sockets/Socket.cs:3184
07-30 20:05:51.883 W/CouchbaseLite(19049): at System.Net.Sockets.Socket.set_DualMode (System.Boolean value) [0x00018] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/System/System.Net.Sockets/Socket.cs:470
07-30 20:05:51.883 W/CouchbaseLite(19049): at Couchbase.Lite.Sync.WebSocketWrapper.b__24_0 () [0x00049] in <6258853c8497443d82418927229b0580>:0
07-30 20:05:51.883 W/CouchbaseLite(19049): at Couchbase.Lite.Support.SerialQueue.ProcessAsync () [0x0002f] in <6258853c8497443d82418927229b0580>:0
[0:] ReplicationStatus changed to Busy.
07-30 20:05:51.893 I/CouchbaseLite(19049): [14] 2017-7-30 08:05:51.897+02:00 SYNC (Replicator) [14] 2017-07-30T20:05:51.8968580+02:00 Replicator[<*> ws://localhost:4984/db] is Connecting, progress 0/0
Thread finished: #13
07-30 20:06:05.073 D/Mono (19049): [0x82cec828] worker finishing
Thread finished: #10
Thread finished: #7
Thread finished: #8
07-30 20:06:45.523 D/Mono (19049): [0x82c8b168] worker finishing

That’s a bonafide bug so please file it as a GH issue. That line is there to allow both IPv4 and IPv6 connections on the same socket but I guess android can’t handle it. This area is currently a gap in our testing because QE is slammed at the moment. I’ll try to think of a solution that doesn’t involve me manually running replications all the time.

Thanks for your assessment! I was in fact wondering.
I just filed it as a github issue as you suggested.