Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-93415

No multicast network interfaces on UWP: socket unable to join multicast group

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.3
    • Fix Version/s: None
    • Component/s: Network
    • Labels:
      None
    • Environment:
      Windows UWP x64
    • Platform/s:
      WinRT

      Description

      This problem causes app to not being able to join multicast groups on UWP platform.

      I printed the flags for network interfaces and they show that no interface has CanMulticast flag set though those network interfaces can multicast.
      So I believe that is the reason, why socket fails to join multicast group if no checks made.

      The same code runs just fine on Windows (non-UWP), Ubuntu, Android, iOS.
      I run this sample on Windows under Virtualbox. But I also tested in real Windows x64 machine and Windows x64 IoT tablet.

      I'll post my code, but QT multicastreceiver example can be used to check, as it has the same issue.

       

          if (m_multicastSocket->state() != QAbstractSocket::BoundState) {
              if (!m_multicastSocket->bind(QHostAddress::AnyIPv4, MULTICAST_HELLO_PORT, QAbstractSocket::ShareAddress | QAbstractSocket::ReuseAddressHint)) {
                  LOGW << "Error: Failed to bind multicast socket!";
                  return;
              }
              else
                  LOGD << "Successfully bound to multicast HELLO port:" << MULTICAST_HELLO_PORT;
      
              const QString& ifName = ClientNetworkManager::instance().desiredInterfaceName();
              if (!ifName.isEmpty())
                  m_multicastSocket->setMulticastInterface(QNetworkInterface::interfaceFromName(ifName));
      
              for (const auto& i : QNetworkInterface::allInterfaces()) {
                  LOGW << "Interface:" << i.name() << "loopback:" << bool(i.flags() & QNetworkInterface::IsLoopBack)
                       << "\nrunning:" << bool(i.flags() & QNetworkInterface::IsRunning)
                       << "\nmulticast:" <<bool(i.flags() & QNetworkInterface::CanMulticast)
                       << "\naddress is empty:" << i.addressEntries().isEmpty();
      
                  if (!(i.flags() & QNetworkInterface::IsLoopBack)
                          && (i.flags() & QNetworkInterface::IsRunning)
                          && (i.flags() & QNetworkInterface::CanMulticast)
                          && (!i.addressEntries().isEmpty()))
                  {
                      if (!m_multicastSocket->joinMulticastGroup(QHostAddress(MULTICAST_HELLO_GROUP), i)) {
                          LOGW << "Error: Joining multicast group failed on interface" << i.name() << i.humanReadableName() << i.hardwareAddress() << "with error:" << m_multicastSocket->errorString();
                      }
                      else
                          LOGW << "Successfully joined multicast group on interface" << i.name() << i.humanReadableName() << i.hardwareAddress();
                  }
              }
          }
      

       

      The log output is:

      Successfully bound to multicast HELLO port: 55555
      
      Interface: "{76FCD10B-5F45-4155-9C42-31960A66A6E2}" loopback: false 
      running: true 
      multicast: false 
      address is empty: false
      
      Interface: "{76FCD10B-5F45-4155-9C42-31960A66A6E2}" loopback: false 
      running: true 
      multicast: false 
      address is empty: true
      

      The log for the same app rebuilt as normal Windows app:

       

      Successfully bound to multicast HELLO port: 55555
      
      Interface: "ethernet_32771" loopback: false
      running: true
      multicast: true
      address is empty: false
      Successfully joined multicast group on interface "ethernet_32771" "vEthernet (Default Switch) 2" "50:15:5D:D0:DB:77"
      
      Interface: "ethernet_32774" loopback: false
      running: true
      multicast: true
      address is empty: false
      Successfully joined multicast group on interface "ethernet_32774" "Ethernet 2" "08:00:27:DC:00:5D"
      
      Interface: "loopback_0" loopback: true
      running: true
      multicast: true
      address is empty: false
      
      Interface: "ethernet_32780" loopback: false
      running: true
      multicast: true
      address is empty: false
      Successfully joined multicast group on interface "ethernet_32780" "vEthernet (nat) 2" "00:15:5D:C8:5C:2A"
      

       

        Attachments

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

          Activity

            People

            Assignee:
            tpochep Timur Pocheptsov
            Reporter:
            rightaway717 Ivan Belyakov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes