couchbase / couchbase-lite-net

A lightweight, document-oriented (NoSQL), syncable database engine for .NET
http://developer.couchbase.com/mobile/
Apache License 2.0
438 stars 126 forks source link

Android socket error when connecting to sync gateway #897

Closed csstrunt closed 7 years ago

csstrunt commented 7 years ago

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. 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.

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

Any ideas?

borrrden commented 7 years ago

What version of Mono are you compiling with and what is your deployment (what kind of device, what version of Android, etc)

borrrden commented 7 years ago

That's just informational, the solution is the same regardless...catch the exception and fall back to IPv4 only.

csstrunt commented 7 years ago

Here is the information:

I tested on two different devices:

  1. sony xperia z5 compact, android 7.1.1
  2. samsung s3 mini, android 4.4.2 with both showing the same error.

Below is the packages.config that was used. `<?xml version="1.0" encoding="utf-8"?>

` **And the Visual Studio Information:** Microsoft Visual Studio Community 2017 Version 15.1 (26403.3) Release VisualStudio.15.Release/15.1.0+26403.3 Microsoft .NET Framework Version 4.7.02046 Installed Version: Community Visual Basic 2017 00369-60000-00001-AA591 Microsoft Visual Basic 2017 Visual C# 2017 00369-60000-00001-AA591 Microsoft Visual C# 2017 Visual C++ 2017 00369-60000-00001-AA591 Microsoft Visual C++ 2017 Visual F# 4.1 00369-60000-00001-AA591 Microsoft Visual F# 4.1 Application Insights Tools for Visual Studio Package 8.6.00209.10 Application Insights Tools for Visual Studio ASP.NET and Web Tools 2017 15.0.30320.0 ASP.NET and Web Tools 2017 ASP.NET Web Frameworks and Tools 2017 5.2.50303.0 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 15.0.30209.0 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.2.5000.0 Microsoft Azure Data Lake Tools for Visual Studio Common Azure Tools 1.9 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events JavaScript Language Service 2.0 JavaScript Language Service JavaScript Project System 2.0 JavaScript Project System JavaScript UWP Project System 2.0 JavaScript UWP Project System KofePackagePackage Extension 1.0 KofePackagePackage Visual Studio Extension Detailed Info Merq 1.1.17-rc (cba4571) Command Bus, Event Stream and Async Manager for Visual Studio extensions. Microsoft Azure Hive Query Language Service 2.2.5000.0 Language service for Hive query Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50131.1 Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio Mono.Debugging.VisualStudio Support for debugging Mono processes with Visual Studio. Node.js Tools 1.3.50316.00 Adds support for developing and debugging Node.js apps in Visual Studio NuGet Package Manager 4.1.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/. Office Developer Tools for Visual Studio 2017 ENU 15.0.26112 Microsoft Office Developer Tools for Visual Studio 2017 ENU SQL Server Data Tools 15.1.61702.140 Microsoft SQL Server Data Tools ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript 2.1.5.0 TypeScript tools for Visual Studio Visual C++ for Cross Platform Mobile Development (Android) 15.0.26228.00 Visual C++ for Cross Platform Mobile Development (Android) Visual Studio tools for CMake 1.0 Visual Studio tools for CMake Visual Studio Tools for Universal Windows Apps 15.0.26403.00 The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit. Workflow Manager Tools 1.0 1.0 This package contains the necessary Visual Studio integration components for Workflow Manager. Xamarin 4.4.0.34 (3f99c5a) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin.Android SDK 7.2.0.7 (b16fb82) Xamarin.Android Reference Assemblies and MSBuild support. Xamarin.iOS and Xamarin.Mac SDK 10.8.0.174 (7656cc6) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. Hope it helps. Thanks for taking care of the issue!