Closed VatsalLahagora closed 2 years ago
Same here. Wifi turned off, using only mobile data. Error is NoReply. Testing google.com
Android or iOS? Which OS version? Real device or simulator?
Android or iOS? Which OS version? Real device or simulator?
Android real device. Android 10.
Thanks for the details! I'll check it out
Oh, one more thing.. Can you download a terminal emulator app and run "ping google.com" and see what it outputs? Then, have dart_ping output the command it is using by calling the .command getter and run that command in the emulator (it will have several flags on it). Compare that output to the other one. This will help diagnose if it is a configuration problem, binary problem, OS problem, or library/app problem.
If any of those steps don't make sense, just lmk. Thanks!
Of course! I check tomorrow @ workplace.
I downloaded termux, and when I run ping google.com command I got no response when I use mobile data only, ping works perfectly when using WiFi. So this behaviour is not your package's fault. Maybe something wrong with APN settings. I'll write if I can solve the problem, maybe it solve @VatsalLahagora problem too.
Thanks for testing that. For what it's worth, it does appear to work over mobile on my android 11 physical device. So it's definitely possible.
After search I found, that my mobile service provider (Telenor Hungary) do not allow pinging.
This is my solution, maybe this helps for @VatsalLahagora:
Ugly but working.
if (widget.networkType == NetworkType.CELLULAR) {
/// If network is cellular
for (int i = 0; i < 3; i++) {
PingData pingData;
final stopwatch = Stopwatch()..start();
await Socket.connect(data.ipOrDomain, 80, timeout: Duration(seconds: 1)).then((socket) async {
socket.destroy();
pingData = PingData(error: null, response: PingResponse(time: stopwatch.elapsed));
}).catchError((error) {
if(error.toString().startsWith("SocketException: Failed host lookup")) {
pingData = PingData(error: PingError(ErrorType.UnknownHost));
} else if(error.toString().startsWith("SocketException: Connection timed out")) {
pingData = PingData(error: PingError(ErrorType.RequestTimedOut));
} else {
pingData = PingData(error: PingError(ErrorType.Unknown));
}
});
}
} else {
/// WiFI, where everything is working
}
Ah sorry to hear that. The solution you came up with is likely the next best thing. Anything else I can help you with or can I close this?
This is not my ticket, but I think the same problem occurring with @VatsalLahagora. I think this ticket is closable.
Fair enough. Closing due to lack of response from OP. Without additional information, cannot reproduce.
Just to clarify, do you have mobile data and wifi connected simultaneously or just mobile data? Are you trying to ping a local or remote resource? What error are you getting?