On Oct 17, 2014, at 1:33 AM, Quinn The Eskimo! < email@hidden> wrote:
It's hard to say what's going on here with the details you've provided (for example, what sort of error do you get when replication fails) but the last part of the quote above piqued my interest. Are you trying to build a URL from a resolved service?
Yes — the OP previously asked this on the Couchbase forum I administer. At that time the problem was that they were generating invalid URLs, by using the textual IPv6 address (which contains colons!) as the hostname. (What is the valid syntax for using a raw IPv6 address as the hostname in a URL?)
If so, I recommend that you avoid the "addresses" array entirely and simply put the host name from the service into the URL. Is that always going to work? I haven't used the NSNetService.hostName property before — does every device running mDNS have a host name? A Mac probably does, presumably the Bonjour hostname configured in the Sharing pref pane, but does an iPhone have a hostname? A printer?
Also, the docs say that the hostName property isn't populated until the service is resolved. At which time the actual IP addresses are also available, so why not just use those?
The advantage of this is that it pushes off the question of address selection until connect time, and your connect-time code is better placed to decide which address to use.
The connect-time code here is the Couchbase Lite library, which the developer doesn't control. I do control it :) but my code just passes the URL to NSURLConnection and/or CFReadStreamCreateForHTTPRequest. Are those going to resolve this hostname properly?
—Jens |