point-source / dart_ping

Multi-platform network ping utility for Dart
30 stars 13 forks source link

Not working #21

Closed t-m-z closed 2 years ago

t-m-z commented 2 years ago

I want to check via an Android app if my server is alive before sending an http-POST-Request. My code is

try{
      final ping = Ping('sdklmfoqdd5qrtha.myfritz.net', count: 3);
      print(ping.command);
      final results = await ping.stream.toList();
      print(results);
    } catch  (exception){
      print(exception);
    }

print(ping.command) shows ping -O -n -W 2 -i 1 -t 255 -c 3 sdklmfoqdd5qrtha.myfritz.net.

The results are PingError(response:PingResponse(seq:1), error:RequestTimedOut), PingError(response:PingResponse(seq:2), error:RequestTimedOut), PingSummary(transmitted:3, received:0), time: 2046 ms, Errors: [RequestTimedOut, RequestTimedOut, NoReply]

However, the server is alive.

point-source commented 2 years ago

Have you tried running ping -O -n -W 2 -i 1 -t 255 -c 3 sdklmfoqdd5qrtha.myfritz.net in a terminal emulator on your device?

t-m-z commented 2 years ago

No - I only used the emulator from Android Studio

point-source commented 2 years ago

That's fine too. Just install a terminal emulator app on the android studio emulator and try running it that way to verify that the android studio emulator can actually ping the device regardless of dart_ping/flutter/dart libraries/frameworks, etc. Just testing the connection

dzakybrori commented 2 years ago

No, that's not fine. I've tried the command on cmd and got badOption.

image

dzakybrori commented 2 years ago

And according to Options that are available. There are some mistake on dart_ping command.

  1. There is no -O / -0.
  2. count command is -n not -c
  3. timeout command is -w not -W
  4. -i use to be ttl not interval. dart_ping use -t for ttl wich is wrong.
  5. What interval params stand for? I don't understand.
dzakybrori commented 2 years ago

Even if I use to ping on google It's got a bad option. image

I tried to change the commend based on Options that are available, and its work. image

Are you sure that dart_ping did not run the wrong command?

dzakybrori commented 2 years ago

Ohh sorry my bad, I run it on windows cmd not Linux terminal.

point-source commented 2 years ago

Yeah, you need to run it in the Android emulator. In a terminal emulator. Every platform has slightly different options because they use different versions or builds or implementations of the ping binary. The only real test is to run the same command it outputs on the exact same device/OS that you are running the app on

point-source commented 2 years ago

Closing due to inactivity. Feel free to reopen if you still need this and have tested in an android terminal emulator