Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to connect when rechability reports not-reachable #633

Merged
merged 2 commits into from
Mar 25, 2015

Conversation

pasin
Copy link
Contributor

@pasin pasin commented Mar 19, 2015

  • Attempt to connect to the remote url when the reachability reports not-reachable. If an offline error returns, bring the replicator offline. Otherwise, bring the replicator online.
  • Used request timeout of 10 seconds.
  • Added autoRetry parameter to CBLRemoteRequest to be able to enable/disable retry feature; set auto retry to NO when trying to check if the server is reachable nor not.
  • Extended NSURLErrorCannotConnectToHost, NSURLErrorCannotFindHost, and NSURLErrorNetworkConnectionLost to the CBLMisc.CBLIsOfflineError method.
    Mac Application Reachability issue #536

- Attempt to connect to the remote url when the rechability reports not-reachable. If an offline error returns, bring the replicator offline. Otherwise, bring the replicator online.

- Used request timeout of 10 seconds.

- Added autoRetry parameter to CBLRemoteRequest to be able to enable/disable retry feature; set auto retry to NO when trying to check if the server is reachable nor not.

- Extended NSURLErrorCannotConnectToHost, NSURLErrorCannotFindHost, and NSURLErrorNetworkConnectionLost to the CBLMisc.CBLIsOfflineError method.

#536
@@ -299,6 +299,9 @@ BOOL CBLIsOfflineError( NSError* error ) {
if ($equal(domain, NSURLErrorDomain))
return code == NSURLErrorDNSLookupFailed
|| code == NSURLErrorNotConnectedToInternet
|| code == NSURLErrorCannotConnectToHost
|| code == NSURLErrorCannotFindHost
|| code == NSURLErrorNetworkConnectionLost
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These error codes don't mean the device is offline, just that the server isn't reachable. I don't think it would be a good idea to have the replicator go offline if, say, the server URL has the wrong port number; this should be reported as an error.

- Add kCBLReplicatorOption_TrustReachability option. The default value is 'YES'. Also setting a value to the kCBLReplicatorOption_Network option will take precendence over and result to always 'Trust'.

- If settings kCBLReplicatorOption_TrustReachability to NO, when the reachability reports offline, the replicator will try to connect to the host and see if it receives any offline related erros or not.

- Rename mayGoOffline method to checkIfOffline.

- Revert CBLMisc.CBLIsOfflineError and add checking NSURLErrorCannotConnectToHost and NSURLErrorNetworkConnectionLost directly to the checkIfOffline method.

#536
@pasin
Copy link
Contributor Author

pasin commented Mar 23, 2015

@snej I push changes per code review and discussion. Please review it again when you have time. Thanks.

snej added a commit that referenced this pull request Mar 25, 2015
…_alwaysoffline

Try to connect when rechability reports not-reachable
@snej snej merged commit 313ea46 into master Mar 25, 2015
@snej snej deleted the feature/issue_536_reachability_alwaysoffline branch March 25, 2015 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants