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

multicast_dns 0.2.0 not detecting mDNS packets #79772

Open
biagiopietro opened this issue Apr 5, 2021 · 24 comments · May be fixed by flutter/packages#6700
Open

multicast_dns 0.2.0 not detecting mDNS packets #79772

biagiopietro opened this issue Apr 5, 2021 · 24 comments · May be fixed by flutter/packages#6700
Labels
found in release: 2.0 Found to occur in 2.0 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: multicast_dns The mdns package P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team triaged-ecosystem Triaged by Ecosystem team

Comments

@biagiopietro
Copy link

biagiopietro commented Apr 5, 2021

I'm trying to do a lookup of a specific service using mDNS but the client in Flutter returns nothing albeit the host (Android Device) received the correct packet from mDNS server (see Wireshark section).

Steps to Reproduce

  1. Create mDNS server (you can use the following code in Go. So you need to put the Go code in a file called main.go and run go get -u github.com/hashicorp/mdns && go run main.go, please make sure you're running that command in the same folder of your main.go. To make sure that the server is running, you can run curl -X GET 'http://localhost:8081/' and then you should receive an ok (see screenshot)
    image
package main

import (
	"fmt"
	"github.com/hashicorp/mdns"
	"os"
  "net/http"
)

func health(w http.ResponseWriter, r *http.Request) {
  fmt.Fprintf(w, "ok")
}

func main() {

	hostname, err := os.Hostname()

	if err != nil {
		panic(fmt.Sprintf("Error getting current hostname, description: %s", err.Error()))
	}

	info := []string{"mDNS get server"}

	service, err := mdns.NewMDNSService(hostname, "_test._tcp", "", "", 8080, nil, info)

	if err != nil {
		panic(fmt.Sprintf("Error while exporting the service, description: %s", err.Error()))
	}

	server, err := mdns.NewServer(&mdns.Config{Zone: service})

	if err != nil {
		panic(fmt.Sprintf("Error while setting the discover server up, description: %s", err.Error()))
	}

	defer server.Shutdown()
	
	http.HandleFunc("/", health)
	http.ListenAndServe(":8081",nil)
}
  1. To check if mDNS server is working you can run (OSX): dns-sd -B _test._tcp (Linux: sudo apt-get install avahi-deamonavahi-utils && avahi-browse -rt _test._tcp)
  2. Regarding flutter you can use:
import 'package:multicast_dns/multicast_dns.dart';
import 'dart:io' show Platform;

Future<void> main() async {
  const String name = '_test._tcp.local';
  MDnsClient client;
  if (Platform.isAndroid) {
     var factory = (dynamic host, int port,
         {bool reuseAddress, bool reusePort, int ttl}) {
       print("Hostname $host");
       print("Port ${port.toString()}");
       return RawDatagramSocket.bind(host, port, reuseAddress: true, reusePort: false, ttl: ttl);
     };
     client = MDnsClient(rawDatagramSocketFactory: factory);
   } else {
     client = MDnsClient();
  }
  // Start the client with default options.
  await client.start();

  // Get the PTR record for the service.
  await for (final PtrResourceRecord ptr in client
      .lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
    // Use the domainName from the PTR record to get the SRV record,
    // which will have the port and local hostname.
    // Note that duplicate messages may come through, especially if any
    // other mDNS queries are running elsewhere on the machine.
    await for (final SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
        ResourceRecordQuery.service(ptr.domainName))) {
      // Domain name will be something like "[email protected]._dartobservatory._tcp.local"
      final String bundleId =
          ptr.domainName; //.substring(0, ptr.domainName.indexOf('@'));
      print('Dart observatory instance found at '
          '${srv.target}:${srv.port} for "$bundleId".');
    }
  }
  client.stop();

  print('Done.');
}
  1. Run flutter run -d <android-device>.

Expected results:
Something like Dart observatory instance found at...

Actual results:

I/ViewRootImpl(28364): jank_removeInvalidNode all the node in jank list is out of time
W/InputMethodManager(28364): startInputReason = 1
I/flutter (28364): Hostname 0.0.0.0
I/flutter (28364): Port 5353
V/AudioManager(28364): playSoundEffect   effectType: 0
V/AudioManager(28364): querySoundEffectsEnabled...
I/flutter (28364): Hostname InternetAddress('127.0.0.1', IPv4)
I/flutter (28364): Port 5353
I/flutter (28364): Hostname InternetAddress('192.168.2.1', IPv4)
I/flutter (28364): Port 5353
I/flutter (28364): Done.
Logs

flutter doctor -v

[✓] Flutter (Channel stable, 2.0.4, on Linux, locale en_US.UTF-8)
    • Flutter version 2.0.4 at /home/puma/snap/flutter/common/flutter
    • Framework revision b1395592de (4 days ago), 2021-04-01 14:25:01 -0700
    • Engine revision 2dce47073a
    • Dart version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /mnt/hd/Android/android-sdk-linux
    • Platform android-30, build-tools 29.0.2
    • Java binary at: /snap/android-studio/current/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio
    • Android Studio at /snap/android-studio/current/android-studio/
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /snap/android-studio/current/android-studio/
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (2 available)
    • ANE LX1 (mobile) • testAndroid • android-arm64  • Android 9 (API 28)
    • Chrome (web)     • chrome           • web-javascript • Google Chrome 89.0.4389.114

• No issues found!

flutter attach --verbose

[ +148 ms] executing: [/home/puma/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +72 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] b1395592de68cc8ac4522094ae59956dd21a91db
[   +1 ms] executing: [/home/puma/snap/flutter/common/flutter/] git tag --points-at b1395592de68cc8ac4522094ae59956dd21a91db
[  +24 ms] Exit code 0 from: git tag --points-at b1395592de68cc8ac4522094ae59956dd21a91db
[        ] 2.0.4
[  +79 ms] executing: [/home/puma/snap/flutter/common/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[   +8 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [/home/puma/snap/flutter/common/flutter/] git ls-remote --get-url origin
[   +9 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +114 ms] executing: [/home/puma/snap/flutter/common/flutter/] git rev-parse --abbrev-ref HEAD
[  +10 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[ +151 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[   +3 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[  +12 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +154 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +123 ms] executing: /mnt/hd/Android/android-sdk-linux/platform-tools/adb devices -l
[  +68 ms] List of devices attached
           testAndroid       device usb:2-1.1 product:ANE-LX1 model:ANE_LX1 device:HWANE transport_id:1
[ +102 ms] /mnt/hd/Android/android-sdk-linux/platform-tools/adb -s testAndroid shell getprop
[ +163 ms] Waiting for a connection from Flutter on ANE LX1...
[ +134 ms] Observatory URL on device: http://127.0.0.1:36421/LB5gpdiwoUU=/
[   +2 ms] executing: /mnt/hd/Android/android-sdk-linux/platform-tools/adb -s testAndroid forward tcp:0 tcp:36421
[  +15 ms] 45003
[   +1 ms] Forwarded host port 45003 to device port 36421 for Observatory
[   +9 ms] Connecting to service protocol: http://127.0.0.1:45003/LB5gpdiwoUU=/
[ +186 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:45003/LB5gpdiwoUU=/.
[ +404 ms] Warning: Failed to start DDS: JSON-RPC error 100: Feature is disabled data: {details: A DDS instance is already connected at http://127.0.0.1:32821/rrJgFvQe3xQ=/., request: {jsonrpc: 2.0, method: _yieldControlToDDS, id: 8, params: {uri:
http://127.0.0.1:37321/2bciKM125Ng=/}}}
[  +55 ms] Successfully connected to service protocol: http://127.0.0.1:45003/LB5gpdiwoUU=/
[   +2 ms] executing: /mnt/hd/Android/android-sdk-linux/platform-tools/adb -s testAndroid shell -x logcat -v time -t 1
[  +84 ms] --------- beginning of main
           04-05 14:15:50.212 I/TrafficMonitor( 1273): gettimer:interval=2000
[ +955 ms] DevFS: Creating new filesystem on the device (null)
[  +18 ms] DevFS: Creating failed. Destroying and trying again
[   +1 ms] DevFS: Deleting filesystem on the device (null)
[  +34 ms] DevFS: Deleted filesystem on the device (null)
[  +15 ms] DevFS: Created new filesystem on the device (file:///data/user/0/com.example.test_mdns_client/code_cache/test_mdns_clientJAQOEZ/test_mdns_client/)
[  +10 ms] Updating assets
[ +299 ms] Syncing files to device ANE LX1...
[   +4 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[  +17 ms] /home/puma/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /home/puma/snap/flutter/common/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root
/home/puma/snap/flutter/common/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names --experimental-emit-debug-metadata --output-dill /tmp/flutter_tools.FDFYPD/flutter_tool.JBRCDK/app.dill
--packages /home/puma/StudioProjects/test_mdns_client/.dart_tool/package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill
build/cache.dill.track.dill
[  +12 ms] <- compile package:test_mdns_client/main.dart

pubspec.yaml

name: test_mdns_client
description: A new Flutter project.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  intl: ^0.15.7
  multicast_dns: any

  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

Wireshark

Source	        Destination	Protocol	Length	Info
192.168.2.1	224.0.0.251	MDNS		76	Standard query 0x0000 PTR _test._tcp.local, "QM" question
192.168.2.4	192.168.2.1	MDNS		180	Standard query response 0x0000 PTR puma._test._tcp.local SRV 10 1 8080 puma A 127.0.1.1 TXT

Where:

  • 192.168.2.1 is testAndroid device;
  • 192.168.2.4 is the device where mDNS server is running on.

Thanks in advance for your help!!!

@TahaTesser TahaTesser added the in triage Presently being triaged by the triage team label Apr 6, 2021
@TahaTesser
Copy link
Member

Hi @biagiopietro
I am not familiar with go but I just installed go and tried your command, i get the following error

tahatesser@Tahas-MBP AndroidStudioProjects % go get github.com/hashicorp/mdns && go run main.go
stat main.go: no such file or directory
tahatesser@Tahas-MBP AndroidStudioProjects % ls
tahatesser@Tahas-MBP AndroidStudioProjects % 

version

tahatesser@Tahas-MBP AndroidStudioProjects % go version
go version go1.16.3 darwin/amd64
tahatesser@Tahas-MBP AndroidStudioProjects % 

Can you please update the reproducible steps
Thank you

@TahaTesser TahaTesser added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 6, 2021
@biagiopietro
Copy link
Author

Hello @TahaTesser,
You need to put the Go code in a file called main.go and run go run main.go, please make sure you're running that command in the same folder of your main.go. To make sure that the server is running, you can run curl -X GET 'http://localhost:8081/' and then you should receive an ok (see screenshot)
image
Please let me know how can I help (reproducible steps updated)

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 6, 2021
@TahaTesser
Copy link
Member

TahaTesser commented Apr 7, 2021

@biagiopietro
I did the same steps, created a folder and main.go file and copied the Go code and ran the command, I get

tahatesser@Tahas-MBP test_go % ls
main.go
tahatesser@Tahas-MBP test_go % go get -u github.com/hashicorp/mdns && go run main.go
main.go:5:2: no required module provides package github.com/hashicorp/mdns: go.mod file not found in current directory or any parent directory; see 'go help modules'
tahatesser@Tahas-MBP test_go % 

Edit:
Tried on a different computer, same error

image

@TahaTesser TahaTesser added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 7, 2021
@biagiopietro
Copy link
Author

biagiopietro commented Apr 7, 2021

@TahaTesser really weird behavior. 😞 I've tried also on OSX and Ubuntu machines without any issue.
Could you please run go mod init main in the same location of your main.go.
It will generate a go.mod file and inside you should put the following line require github.com/hashicorp/mdns v1.0.3 (after module main).
Once you are done please save the file and run again go run main.go (see screenshot for more details)
image

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 7, 2021
@biagiopietro
Copy link
Author

I saw that you are using Go version go1.16.3 so I upgraded also to that version and I tried the steps described before and they worked for me

@TahaTesser
Copy link
Member

Hi @biagiopietro
Thanks for the details, go mod init main did the trick and main.go is running and curl -X GET 'http://localhost:8081/' is returning ok

DNS - main.go preview

image
image (1)

logs
Launching lib/main.dart on RMX2001 in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:45587/dDUB8u2-dhU=/ws
I/flutter (15328): Hostname 0.0.0.0
I/flutter (15328): Port 5353
I/flutter (15328): Hostname InternetAddress('127.0.0.1', IPv4)
I/flutter (15328): Port 5353
I/flutter (15328): Hostname InternetAddress('192.168.0.159', IPv4)
I/flutter (15328): Port 5353
D/ColorViewRootUtil(15328): nav gesture mode swipeFromBottom ignore false downY 1242 mScreenHeight 2400 mScreenWidth 1080 mStatusBarHeight 54 globalScale 1.125 nav mode 3 event MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=432.0, y[0]=1242.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=291572, downTime=291572, deviceId=3, source=0x1002, displayId=0 } rotation 0
I/flutter (15328): Done.
I/SurfaceView(15328): 229261539 visibleChanged:true -> SurfaceHolder.Callback.surfaceDestroyed
D/Surface (15328): Surface::disconnect(this=0x70d00e6000,api=1)
D/ViewRootImpl(15328): setSurfaceViewCreated, created:false
D/Surface (15328): Surface::disconnect(this=0x70d00e6000,api=-1)
D/SurfaceView(15328): updateScreenMode w:0 h:0 ViewRoot w:1080 h:2400
D/SurfaceView(15328): try to resquest 90Hz
D/ViewRootImpl(15328): set screen refresh mode 0 due to SurfaceView-229261539
I/Choreographer(15328): Skipped 5 frames!  The application may be doing too much work on its main thread.
I/GED     (15328): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 27, oppidx_max 27, oppidx_min 0
D/Surface (15328): Surface::disconnect(this=0x70d00e4000,api=1)
V/PhoneWindow(15328): DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@89f9b74, this = DecorView@9560761[MainActivity]
dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  multicast_dns: ^0.2.2 
flutter doctor -v
taha@taha-Lenovo-ideapad-510S-14IKB:~/AndroidStudioProjects$ fsd
[✓] Flutter (Channel stable, 2.0.4, on Linux, locale en_IN)
    • Flutter version 2.0.4 at /home/taha/Code/flutter_stable
    • Framework revision b1395592de (6 days ago), 2021-04-01 14:25:01 -0700
    • Engine revision 2dce47073a
    • Dart version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/taha/Code/SDK
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /home/taha/Code/SDK
    • Java binary at: /home/taha/Code/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.
[✓] Chrome - develop for the web
    • Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1
[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup
      for detailed instructions).
[✓] Connected device (3 available)
    • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64  • Android 10 (API 29)
    • Linux (desktop)  • linux            • linux-x64      • Linux
    • Chrome (web)     • chrome           • web-javascript • Google Chrome
      89.0.4389.90
! Doctor found issues in 1 category.
taha@taha-Lenovo-ideapad-510S-14IKB:~/AndroidStudioProjects$ 

Thanks for filing the issue

@TahaTesser TahaTesser added found in release: 2.0 Found to occur in 2.0 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: first party p: multicast_dns The mdns package package flutter/packages repository. See also p: labels. and removed in triage Presently being triaged by the triage team labels Apr 8, 2021
@MarcelKr
Copy link

MarcelKr commented Jun 17, 2021

I can confirm that it's also not working for multicast_dns 0.3.0. Tested using a Pixel 3 and an emulated Pixel 3 from a linux host. Using Flutter 2.2.1. I verified via wireshark that the mDNS is answering.

The code has some minor adaptions:

import 'package:multicast_dns/multicast_dns.dart';
import 'dart:io';

Future<void> main() async {
  const String name = '_test._tcp.local';
  MDnsClient client;
  if (Platform.isAndroid) {
    var factory = (dynamic host, int port,
        {bool reuseAddress = true, bool reusePort = true, int ttl = 10000}) {
      print("Hostname $host");
      print("Port ${port.toString()}");
      return RawDatagramSocket.bind(host, port,
          reuseAddress: true, reusePort: false, ttl: ttl);
    };
    client = MDnsClient(rawDatagramSocketFactory: factory);
  } else {
    client = MDnsClient();
  }
  // Start the client with default options.
  await client.start();

  // Get the PTR record for the service.
  await for (final PtrResourceRecord ptr in client
      .lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
    // Use the domainName from the PTR record to get the SRV record,
    // which will have the port and local hostname.
    // Note that duplicate messages may come through, especially if any
    // other mDNS queries are running elsewhere on the machine.
    await for (final SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
        ResourceRecordQuery.service(ptr.domainName))) {
      // Domain name will be something like "[email protected]._dartobservatory._tcp.local"
      final String bundleId =
          ptr.domainName; //.substring(0, ptr.domainName.indexOf('@'));
      print('Dart observatory instance found at '
          '${srv.target}:${srv.port} for "$bundleId".');
    }
  }
  client.stop();

  print('Done.');
}

@stuartmorgan stuartmorgan added the P2 Important issues not at the top of the work list label Oct 20, 2021
@MarcelKr
Copy link

Is anyone aware of a workaround for this problem?

This package is currently kind of useless on android since the core functionality is broken. I don't understand why this got such a low priority.

@MarcelKr
Copy link

MarcelKr commented Dec 30, 2021

Well, for some reason it seems to be working currently on my Pixel 3a @ Android 12.
The plugin version is 0.3.1.

Can anyone confirm this?

flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on Arch Linux 5.15.11-arch2-1, locale de_DE.UTF-8)
    • Flutter version 2.8.1 at /home/marcel/devtools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (vor 2 Wochen), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /home/marcel/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2020.3)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 62.0.1
    • Dart plugin version 203.8452
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

@szekelyisz
Copy link

I have 2 phones, one with Android 9 that does receive mDNS replies, and one with Android 10 that doesn't.

multicast_dns 0.3.2

flutter doctor -v

[✓] Flutter (Channel stable, 2.5.3, on Debian GNU/Linux 11 (bullseye) 5.10.0-13-amd64, locale en_CA.UTF-8)
    • Flutter version 2.5.3 at /home/szabi/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (6 months ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /home/szabi/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /snap/android-studio/119/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2021.1)
    • Android Studio at /snap/android-studio/119/android-studio
    • Flutter plugin version 65.2.2
    • Dart plugin version 211.7811
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] VS Code
    • VS Code at /snap/code/current
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • ONEPLUS A6013 (mobile) • acd40725 • android-arm64 • Android 9 (API 28)

! Doctor found issues in 1 category.

@m4rcelknu
Copy link

Same problem on the Pixel 4a @android 12.

@exaby73
Copy link
Member

exaby73 commented May 19, 2022

I have tested this on the latest stable and master channels. I could not reproduce this. I'm using multicast_dns: ^0.3.2 for context. @biagiopietro can you please confirm on your end as well?

Logs (Vivo V21, Android 12)
I/flutter (20071): Hostname 0.0.0.0
I/flutter (20071): Port 5353
I/flutter (20071): Hostname InternetAddress('127.0.0.1', IPv4)
I/flutter (20071): Port 5353
I/flutter (20071): Hostname InternetAddress('192.168.0.101', IPv4)
I/flutter (20071): Port 5353
Syncing files to device V2050...                                    70ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

💪 Running with sound null safety 💪

An Observatory debugger and profiler on V2050 is available at: http://127.0.0.1:55891/oqaJlqBii3w=/
I/ode.issue_7977(20071): Compiler allocated 4338KB to compile void android.view.ViewRootImpl.performTraversals()
I/flutter (20071): Done.
E/ion     (20071): ioctl c0044901 failed with code -1: Invalid argument
D/hw-ProcessState(20071): Binder ioctl to enable oneway spam detection failed: Invalid argument
E/OpenGLRenderer(20071): fbcNotifyFrameComplete error: undefined symbol: fbcNotifyFrameComplete
E/OpenGLRenderer(20071): fbcNotifyNoRender error: undefined symbol: fbcNotifyNoRender
V/ImeFocusController(20071): onWindowFocus: DecorView@7fe2c8[MainActivity] softInputMode=STATE_UNSPECIFIED|ADJUST_RESIZE|IS_FORWARD_NAVIGATION
V/ImeFocusController(20071): Restarting due to isRestartOnNextWindowFocus as true
D/ImeFocusController(20071): onViewFocusChanged, view=DecorView@7fe2c8[MainActivity], mServedView=null
V/ImeFocusController(20071): checkFocus: view=null next=DecorView@7fe2c8[MainActivity] force=true package=<none>
The Flutter DevTools debugger and profiler on V2050 is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:55891/oqaJlqBii3w=/

Similar logs are outputted when I tested an emulated Pixel 4 running Android 12 (API 32) and Android 11 (API 30).


Code sample
import 'package:flutter/material.dart';
import 'package:multicast_dns/multicast_dns.dart';
import 'dart:io' show Platform, RawDatagramSocket;

Future<void> main() async {
  const String name = '_test._tcp.local';
  MDnsClient client;
  if (Platform.isAndroid) {
    Future<RawDatagramSocket> factory(
      dynamic host,
      int port, {
      bool reuseAddress = false,
      bool reusePort = false,
      int ttl = 10,
    }) {
      print("Hostname $host");
      print("Port ${port.toString()}");
      return RawDatagramSocket.bind(
        host,
        port,
        reuseAddress: true,
        reusePort: false,
        ttl: ttl,
      );
    }

    client = MDnsClient(rawDatagramSocketFactory: factory);
  } else {
    client = MDnsClient();
  }
  // Start the client with default options.
  await client.start();

  // Get the PTR record for the service.
  await for (final PtrResourceRecord ptr in client
      .lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
    // Use the domainName from the PTR record to get the SRV record,
    // which will have the port and local hostname.
    // Note that duplicate messages may come through, especially if any
    // other mDNS queries are running elsewhere on the machine.
    await for (final SrvResourceRecord srv in client.lookup<SrvResourceRecord>(
        ResourceRecordQuery.service(ptr.domainName))) {
      // Domain name will be something like "[email protected]._dartobservatory._tcp.local"
      final String bundleId =
          ptr.domainName; //.substring(0, ptr.domainName.indexOf('@'));

      print(
        'Dart observatory instance found at '
        '${srv.target}:${srv.port} for "$bundleId".',
      );
    }
  }
  client.stop();

  print('Done.');

  runApp(const MaterialApp());
}
flutter doctor -v (Stable)
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm, locale en-US)
    • Flutter version 3.0.0 at /Users/nabeelparkar/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (7 days ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/nabeelparkar/Library/Android/sdk/
    • Platform android-32, build-tools 32.1.0-rc1
    • ANDROID_SDK_ROOT = /Users/nabeelparkar/Library/Android/sdk/
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Brave Browser.app/Contents/MacOS/Brave Browser

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 67.1.4
    • Dart plugin version 221.5591.52

[✓] VS Code (version 1.67.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.3.1 21E258 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Brave Browser 101.1.38.115

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
flutter doctor -v (Master)
[✓] Flutter (Channel master, 3.1.0-0.0.pre.799, on macOS 12.3.1 21E258 darwin-arm, locale en-US)
    • Flutter version 3.1.0-0.0.pre.799 at /Users/nabeelparkar/fvm/versions/master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 348a2b4f2f (2 hours ago), 2022-05-19 00:33:08 -0400
    • Engine revision 1965c92ea4
    • Dart version 2.18.0 (build 2.18.0-130.0.dev)
    • DevTools version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/nabeelparkar/Library/Android/sdk/
    • Platform android-32, build-tools 32.1.0-rc1
    • ANDROID_SDK_ROOT = /Users/nabeelparkar/Library/Android/sdk/
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Brave Browser.app/Contents/MacOS/Brave Browser

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 67.1.4
    • Dart plugin version 221.5591.52

[✓] VS Code (version 1.67.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (4 available)
    • V2050 (mobile)            • 3085425058000NM • android-arm64  • Android 12 (API 31)
    • sdk gphone arm64 (mobile) • emulator-5554   • android-arm64  • Android 11 (API 30) (emulator)
    • macOS (desktop)           • macos           • darwin-arm64   • macOS 12.3.1 21E258 darwin-arm
    • Chrome (web)              • chrome          • web-javascript • Brave Browser 101.1.38.119

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@exaby73 exaby73 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 19, 2022
@MarcelKr
Copy link

MarcelKr commented May 19, 2022

Just retested, these are my results:

Pixel 3a - Android 12 - Works
Pixel 5 - Android 12 - Works
Xiaomi Mi A2 Lite - Android 11 - Broken
Huawei P30 Lite - Android 10 - EMUI 10.0.0.491 - Broken

multicast_dns 0.3.2

flutter doctor -v
[✓] Flutter (Channel stable, 3.0.0, on Arch Linux 5.17.7-arch1-1, locale de_DE.UTF-8)
    • Flutter version 3.0.0 at /home/marcel/devtools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (vor 10 Tagen), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /home/marcel/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2021.1)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 65.2.2
    • Dart plugin version 211.7811
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2022.1)
    • IntelliJ at /usr/share/idea
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (1 available)
    • MAR LX1A (mobile) • L2NDU20313004218 • android-arm64 • Android 10 (API 29)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

@exaby73 exaby73 added found in release: 3.0 Found to occur in 3.0 found in release: 3.1 Found to occur in 3.1 and removed found in release: 2.0 Found to occur in 2.0 labels May 19, 2022
@exaby73
Copy link
Member

exaby73 commented May 19, 2022

@MarcelKr Thanks for the input. Can you confirm if this only occurs on Android or does it reproduce on iOS too?

@MarcelKr
Copy link

Unfortunately I don't have an iOS device currently

@exaby73
Copy link
Member

exaby73 commented May 20, 2022

Okay thanks for you input 😄

@github-actions
Copy link

github-actions bot commented Jun 9, 2022

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

@github-actions github-actions bot closed this as completed Jun 9, 2022
@MarcelKr
Copy link

MarcelKr commented Jun 9, 2022

Why has this issue been closed? :/

@exaby73
Copy link
Member

exaby73 commented Jun 9, 2022

The waiting for customer response was applied for more than 27 days. Since @biagiopietro hasn't replied, the bot marked this as timeout. The label is only removed with OP responds.

@exaby73 exaby73 reopened this Jun 9, 2022
@exaby73
Copy link
Member

exaby73 commented Jun 9, 2022

Since I was unable to reproduce it, I am removing the found in labels though keeping this issue open. It was a mistake on to add them with reproduction on my end

@exaby73 exaby73 added found in release: 2.0 Found to occur in 2.0 and removed waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds found in release: 3.0 Found to occur in 3.0 found in release: 3.1 Found to occur in 3.1 labels Jun 9, 2022
@flutter-triage-bot flutter-triage-bot bot added team-ecosystem Owned by Ecosystem team triaged-ecosystem Triaged by Ecosystem team labels Jul 8, 2023
@mbalmer
Copy link

mbalmer commented Feb 25, 2024

This is still not working properly as of today. A mDNS resolver on my device shows me what I am looking for, but multicast_dns usually does not resolve anything. Sometimes it does....

@biagiopietro
Copy link
Author

biagiopietro commented May 2, 2024

Hello everyone,
My apologies for the long absence on this.
I will try to follow up again, from what I checked looks like that there are some edge cases on network level that are not handled properly.
I need to dust off again wireshark and have a deep look.

@biagiopietro
Copy link
Author

biagiopietro commented May 9, 2024

Hi @MarcelKr ,@mbalmer, @exaby73
It took a while to investigate a possible solution, I put findings and 2 proposals in the following PR (I just applied one)

Please I'm not an expert and I would like to have also your eyes on it.

(Having a confirmation that it fixes also in your case is really appreciated)

@MarcelKr
Copy link

Hey @biagiopietro. Thanks for taking the time in attempting to fix this, that's really cool! However I'm absolutely not confident in making any judgement on the PR since I'm neither an expert in dart (which would probably not be the big issue here) nor in the details one needs to know about networking to add profound statements unfortunately :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
found in release: 2.0 Found to occur in 2.0 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: multicast_dns The mdns package P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team triaged-ecosystem Triaged by Ecosystem team
Projects
None yet
9 participants