“Endpoint not reachable”
I’m looking for some advice as to how I can track my problem down - I’ve broken something and I’m not sure where :-(.
I have a C# app that runs on iOS and the Mac (lots of shared code, especially the data management).
I decided it was time to switch everything to TLS and to turn off the App Transport Security (ATS) workaround. I made CA key/cert and wildcard server key/cert/chain (*.xyz.org). I’ve installed the CA cert on the iPhone simulator and on my Mac. I’m confident the certs are good because I can browse to the SSL Web/REST server from the mac and iPhone and dont get any cert warnings plus “openssl verify” validates the chain (I’ve spent waaaay too long working with openssl and TLS in the past, so my openssl-fu is pretty good).
The iPhone app on the simulator is less happy - it can connect to the REST service via TLS, but it can’t seem to connect to the sync service. This is shared code - so both apps are running exactly the same code to create the replication objects.
I’ve turned on Couchbase logging - and here’s what I see:
INFO) SYNC (Replication):  2018-3-27 02:03:47.010+13:00 Attempting to start puller (a38ce72d-6e09-4962-baa8-1c62cd82a222) INFO) SYNC (Replication):  2018-3-27 02:03:47.011+13:00 Attempting to start pusher (3b7fd8ca-db2f-4ed0-be9e-cd88ad0482ee) INFO) SYNC (NetworkReachabilityManager):  2018-3-27 02:03:47.029+13:00 Didn't get successful connection to http://dbserver.xyz.org:4984/private INFO) SYNC (NetworkReachabilityManager):  2018-3-27 02:03:47.030+13:00 Didn't get successful connection to http://dbserver.xyz.org:4984/private INFO) SYNC (Replication):  2018-3-27 02:03:47.030+13:00 Remote endpoint is not reachable, going offline... INFO) SYNC (Replication):  2018-3-27 02:03:47.030+13:00 Remote endpoint is not reachable, going offline... System.NullReferenceException: Object reference not set to an instance of an object at Couchbase.Lite.NetworkReachabilityManager.CanReach (Couchbase.Lite.Internal.RemoteSession session, System.String remoteUri, System.TimeSpan timeout) [0x0000c] in /Users/jenkins/jenkins/workspace/couchbase-lite-net-build/1.4.1/iOS/couchbase-lite-net/src/Couchbase.Lite.Shared/Manager/NetworkReachabilityManager.cs:56
Just to check there wasn’t something weird happening with name resolution - I wrote some code to check names/ips just before starting the sync, and whether the port is open. The results were as expected:
(I also checked ports that I knew would be closed to be sure my port checker was working).
dbserver.xyz.org resolves to 192.168.80.127 (this is correct - running on VM with local IP). appserver.xyz.org resolves to 127.0.0.1 (this is correct - test REST server running locally) dbserver.xyz.org:4984 is open (std sync port) dbserver.xyz.org:4986 is closed (correct - not used) appserver.xyz.org:5000 is open (REST service) appserver.xyz.org:5002 is closed (correct - not used)
Lastly I turned off TLS (and added the ATS workaround). Again, the Mac is happy and the iOS app fails to connect to the sync server, but still connects to my App/REST service.
- Mac and iOS share Sync code.
- Mac works fine over TLS and HTTP to REST Service and Sync Service
- iOS works over TLS and HTTP to REST Service, fails to connect to Sync Service over HTTP and TLS.
- iOS app can open the sync gateway port… but the couchbase library cannot.
So the problem is not just with the TLS connection - I’ve broken something somewhere.
Lastly, I also checked git - there have been no changes to the shared code that starts the sync engine.
a) Is there something that could impact the reachability code?
b) Is the System.NullReferenceException relevant/important?
Thanks for advice as to how I can track this down.