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
Comments
Hi @biagiopietro
version
Can you please update the reproducible steps |
Hello @TahaTesser, |
@biagiopietro
Edit: |
@TahaTesser really weird behavior. 😞 I've tried also on |
I saw that you are using |
Hi @biagiopietro logsLaunching 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 -vtaha@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 |
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.');
} |
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. |
Well, for some reason it seems to be working currently on my Pixel 3a @ Android 12. Can anyone confirm this? flutter doctor -v
|
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
|
Same problem on the Pixel 4a @android 12. |
I have tested this on the latest stable and master channels. I could not reproduce this. I'm using Logs (Vivo V21, Android 12)
Similar logs are outputted when I tested an emulated Pixel 4 running Android 12 (API 32) and Android 11 (API 30). Code sampleimport '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());
}
|
Just retested, these are my results: Pixel 3a - Android 12 - Works multicast_dns 0.3.2
|
@MarcelKr Thanks for the input. Can you confirm if this only occurs on Android or does it reproduce on iOS too? |
Unfortunately I don't have an iOS device currently |
Okay thanks for you input 😄 |
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. |
Why has this issue been closed? :/ |
The |
Since I was unable to reproduce it, I am removing the |
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.... |
Hello everyone, |
Hi @MarcelKr ,@mbalmer, @exaby73 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) |
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 :/ |
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 frommDNS server
(see Wireshark section).Steps to Reproduce
mDNS server
(you can use the following code inGo
. So you need to put theGo
code in a file calledmain.go
and rungo get -u github.com/hashicorp/mdns && go run main.go
, please make sure you're running that command in the same folder of yourmain.go
. To make sure that the server is running, you can runcurl -X GET 'http://localhost:8081/'
and then you should receive anok
(see screenshot)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
)flutter run -d <android-device>
.Expected results:
Something like
Dart observatory instance found at...
Actual results:
Logs
flutter doctor -v
flutter attach --verbose
pubspec.yaml
Wireshark
Where:
192.168.2.1
istestAndroid
device;192.168.2.4
is the device where mDNS server is running on.Thanks in advance for your help!!!
The text was updated successfully, but these errors were encountered: