Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-1268

ListenerURL returns Hostname.local instead of LocalHostname.local

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0
    • Helium
    • LiteCore
    • Security Level: Public
    • None
    • Build Team 2020 Sprint 18
    • 3

    Description

      Edit: After Ming Ho helped me with information to reproduce the issue, updating the description

      When the mac machine has HostName as well as LocalHostname, API returns `<hostname>+.local` as listener URL

      Steps:
      1. `scutil --set LocalHostName`, set it to LocalHostName
      2. `scutil --set HostName`, set it to HostName

      couchbase-lite-ios 20:09:40 $ scutil --set LocalHostName
      LocalHostName [JayMachine]: LocalHostName
      couchbase-lite-ios 20:09:53 $ scutil --get LocalHostName
      LocalHostName
      couchbase-lite-ios 20:14:59 $ scutil --set HostName
      HostName [JayHostName]: HostName
      couchbase-lite-ios 20:15:17 $ scutil --get HostName
      HostName
      

      3. Start the listener in iPhone simulator on same mac
      4. Check `listener.url` contains `wss://hostname.local:4985/db`

      2020-09-08 20:11:44.917955-0700 CBL_EE_Tests[61514:2035910] *** URL: (
          "wss://HostName.local:4985/otherdb",
          ..... 
      )
      

      5. Check the System Preferences > Sharing , you will see the <localhost>.local as local network name.

      Expected result:
      `listsner.url` should contain `wss://LocalHostName.local:4985/otherdb` instead of `wss://HostName.local:4985/otherdb`

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            Jayahari.Vavachan Jay Vavachan added a comment - may be helpful? https://discussions.apple.com/thread/7707202
            ming.ho Ming Ho added a comment -

            @Jay Vavachan please see attached screenshot.  VM's system preference is <hostname>.sc.couchbase.com (real IP) or <hostname>.local (127.0.0.1)

            ming.ho Ming Ho added a comment - @ Jay Vavachan please see attached screenshot.  VM's system preference is <hostname>.sc.couchbase.com (real IP) or <hostname>.local (127.0.0.1)
            Jayahari.Vavachan Jay Vavachan added a comment -

            From the logs, it is using the real IP `CouchbasesMini3.sc.****.com.local:4985`, but it is timing out.

            Jayahari.Vavachan Jay Vavachan added a comment - From the logs, it is using the real IP `CouchbasesMini3.sc.****.com.local:4985`, but it is timing out.
            jimb Jim Borden added a comment -

            Jens Alfke Can you evaluate what this will take and whether it's worth keeping the host name around?

            jimb Jim Borden added a comment - Jens Alfke Can you evaluate what this will take and whether it's worth keeping the host name around?
            pasin Pasin Suriyentrakorn added a comment - - edited

            Jay Vavachan does the test fail on macOS or iOS?

            Here is the source code in LiteCore to get the local host name for Apple platform:

            https://github.com/couchbase/couchbase-lite-core/blob/55f36615ac8b9ee39bb93720676d6e87795d85e5/Networking/NetworkInterfaces.cc#L242-L269

            If the test failed on an iOS Simulator, likely that the issue will not happen on the device as the issue seems to be the side effect of setting the hostname to the mac machine. So if this is the case, it's not a high priority to fix it in hydrogen. 

            pasin Pasin Suriyentrakorn added a comment - - edited Jay Vavachan does the test fail on macOS or iOS? Here is the source code in LiteCore to get the local host name for Apple platform: https://github.com/couchbase/couchbase-lite-core/blob/55f36615ac8b9ee39bb93720676d6e87795d85e5/Networking/NetworkInterfaces.cc#L242-L269 If the test failed on an iOS Simulator, likely that the issue will not happen on the device as the issue seems to be the side effect of setting the hostname to the mac machine. So if this is the case, it's not a high priority to fix it in hydrogen. 
            Jayahari.Vavachan Jay Vavachan added a comment -

            It fails on `CBL_EE_ObjC_Tests_iOS_App > iPhone simulator SE `

            Jayahari.Vavachan Jay Vavachan added a comment - It fails on `CBL_EE_ObjC_Tests_iOS_App > iPhone simulator SE `
            jimb Jim Borden added a comment -

            It doesn't appear to function on the device either, but furthermore there doesn't seem to be any separate settings for "local hostname" vs "hostname" which leads me to believe that this will never work on iOS (and possibly macOS on separate machines) without running NSNetService to advertise the service first.

            jimb Jim Borden added a comment - It doesn't appear to function on the device either, but furthermore there doesn't seem to be any separate settings for "local hostname" vs "hostname" which leads me to believe that this will never work on iOS (and possibly macOS on separate machines) without running NSNetService to advertise the service first.
            jens Jens Alfke added a comment -

            That's not how it works — it's not related to NSNetService. On a device with mDNS support, the DNS resolver uses mDNS queries to resolve hostnames in the ".local" domain.

            I don't know why lookups aren't working sometimes on iOS. And it does seem like there's a problem in the Simulator that if the Mac has a static DNS name, our code will wrongly get that as the mDNS name. So I agree with taking out the hostname on iOS.

            jens Jens Alfke added a comment - That's not how it works — it's not related to NSNetService. On a device with mDNS support, the DNS resolver uses mDNS queries to resolve hostnames in the ".local" domain. I don't know why lookups aren't working sometimes on iOS. And it does seem like there's a problem in the Simulator that if the Mac has a static DNS name, our code will wrongly get that as the mDNS name. So I agree with taking out the hostname on iOS.

            People

              The Lite The Lite
              Jayahari.Vavachan Jay Vavachan
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty