-
Notifications
You must be signed in to change notification settings - Fork 14
Does not catch/report "Network is unreachable" errors on Android #20
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
Comments
Are you by chance using a language other than English for your Android system/OS primary language? Have you tried debugging or printing out any exceptions that get caught? It seems to me that your code would fail silently in the event of an exception being thrown. |
No. English is the primary language. I added a breakpoint in both One thing that I noticed, is that when I also ping with Termux (after connecting with my app), I also get |
Well, I would say it's probably a bug that it isn't returning anything at all. It should at least return or throw the error but I need to figure out how to reproduce this and so far I haven't been able to. |
I could keep this code for some time in my app and try to find what's happening, but I need to know where should I add some logs. |
A good place to start would be to try the raw command like so: Future<bool> _ping() async {
try {
final ping = Ping(ipAddress, count: 4);
print(ping.command); // Outputs the command that will be sent to the shell/ping process
final results = await ping.stream.toList();
if (results.isEmpty) {
return false;
}
final summary = results.last.summary!;
final successRate = summary.received / summary.transmitted;
return successRate > 0.5;
} catch (e) {
return false;
}
} Then, copy that command and run it in a terminal emulator on your Android device or emulator and see what it does. If it outputs an error that isn't being caught by dart_ping, then copy that error here as a comment so I can add parsing for it. |
Ok. I'll try to do this tomorrow morning
…On Tue, 15 Feb 2022 at 21:58, PointSource ***@***.***> wrote:
A good place to start would be to try the raw command like so:
Future<bool> _ping() async {
try {
final ping = Ping(ipAddress, count: 4);
print(ping.command); // Outputs the command that will be send to the shell/ping process
final results = await ping.stream.toList();
if (results.isEmpty) {
return false;
}
final summary = results.last.summary!;
final successRate = summary.received / summary.transmitted;
return successRate > 0.5;
} catch (e) {
return false;
}
}
Then, copy that command and run it in a terminal emulator on your Android
device or emulator and see what it does. If it outputs an error that isn't
being caught by dart_ping, then copy that error here as a comment so I can
add parsing for it.
—
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or unsubscribe
<https://github.com./notifications/unsubscribe-auth/AE3FQASE6KQPNHPDY3RXBH3U3LZDPANCNFSM5OEXR5YA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
The output of |
Okay. Looks like I need to see why dart_ping isn't catching that error and reporting it back to you. Nonetheless, the fact that you can't ping it due to the network being unreachable is a separate issue between your devices and not related to this package. I will work on getting dart_ping to be more informative about this. Thanks |
I was able to reproduce this error by statically assigning an IP address outside of the subnet. The errors I get are I can submit a PR for this. I'll add new |
The code above always return immediately, doesn't matter if I set the
count
to 4 or 40. Theresult
is always empty and immediate.I'm using an Android 11 and the
ipAddress
is from an iot device (without internet) that I'm connected to.Also, when using emulated terminals I get "Network is unreachable", but my app can properly communicate with the device.
The text was updated successfully, but these errors were encountered: