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

ListenerURL returns Hostname.local instead of LocalHostname.local

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 3.0
    • Helium
    • LiteCore
    • Security Level: Public
    • None
    • Build Team 2020 Sprint 18, LiteCore 94
    • 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

            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.
            jimb Jim Borden added a comment -

            This ticket is regarding something that is not even used anywhere except in testing and an unused method on the REST server (which is used in the cblite command line tool, not the litecore library).  Is there some reason for testing it and trying to fix it Jay Vavachan ?

            jimb Jim Borden added a comment - This ticket is regarding something that is not even used anywhere except in testing and an unused method on the REST server (which is used in the cblite command line tool, not the litecore library).  Is there some reason for testing it and trying to fix it Jay Vavachan ?
            callum.birks Callum Birks added a comment -

            I've tested this both on the Simulator and on an actual iOS device. The issue only appears on the simulator, and only when you have set HostName and LocalHostName in terminal. If you haven't set those hostnames, in Simulator it will show up with your Mac's hostname (i.e. "Callums-MacBook-Pro.local". On a device it shows up as i.e. "Callums-iPhone-12.local".

            callum.birks Callum Birks added a comment - I've tested this both on the Simulator and on an actual iOS device. The issue only appears on the simulator, and only when you have set HostName and LocalHostName in terminal. If you haven't set those hostnames, in Simulator it will show up with your Mac's hostname (i.e. "Callums-MacBook-Pro.local". On a device it shows up as i.e. "Callums-iPhone-12.local".
            callum.birks Callum Birks added a comment -

            Issue is only prevalent on Simulator, and only when HostName and LocalHostName have been set.

            callum.birks Callum Birks added a comment - Issue is only prevalent on Simulator, and only when HostName and LocalHostName have been set.

            People

              callum.birks Callum Birks
              Jayahari.Vavachan Jay Vavachan
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty