-
Couldn't load subscription status.
- Fork 29.4k
Open
Labels
in triagePresently being triaged by the triage teamPresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
Description
I’m using Flutter’s multicast_dns package to discover Android TVs on the local network using mDNS. The code works perfectly on the iOS simulator, but fails on a real iPhone with the following error:
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: SocketException: Send failed (OS Error: No route to host, errno = 65), address = 0.0.0.0, port = 5353
#0 _NativeSocket.send (dart:io-patch/socket_patch.dart:1521:34)
#1 _RawDatagramSocket.send (dart:io-patch/socket_patch.dart:3078:15)
#2 MDnsClient.lookup (package:multicast_dns/multicast_dns.dart:227:22)Future<void> search() async {
const String name = '_androidtvremote2._tcp';
final MDnsClient client = MDnsClient();
try {
await client.start();
await for (final PtrResourceRecord ptr in client
.lookup<PtrResourceRecord>(ResourceRecordQuery.serverPointer(name))) {
final fullName = ptr.domainName;
final friendlyName = fullName.split('.')[0];
await for (final SrvResourceRecord srv in client
.lookup<SrvResourceRecord>(
ResourceRecordQuery.service(ptr.domainName),
)) {
final host = srv.target;
final port = srv.port;
await for (final IPAddressResourceRecord addr in client
.lookup<IPAddressResourceRecord>(
ResourceRecordQuery.addressIPv4(host),
)) {
final ip = addr.address.address;
print('Found $friendlyName at $ip:$port');
}
}
}
client.stop();
} catch (error) {
print(error);
}
}I’ve already done the following:
-
Added NSLocalNetworkUsageDescription in Info.plist.
-
Added NSBonjourServices with _androidtvremote2._tcp.
-
Local network permission is ON in iOS Settings.
-
Works fine on iOS simulator and Android devices.
-
Both iPhone and Android TV are on the same Wi-Fi.
Despite all that, it always throws SocketException (OS Error: No route to host, errno = 65) on a real iPhone.
Metadata
Metadata
Assignees
Labels
in triagePresently being triaged by the triage teamPresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds