point-source / dart_ping

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

ping.stop() isn't closing the stream on an unknownHost error #30

Open endlessxaura opened 1 year ago

endlessxaura commented 1 year ago

This is my future:

    Ping ping = Ping('fooey', count: 5, timeout: 10);
    ...
        StreamBuilder(
          stream: ping.stream,
          builder: (context, AsyncSnapshot<PingData> snapshot) {
            print(snapshot);
            print(ping.command);
            if (snapshot.connectionState != ConnectionState.done) {
              if (snapshot.hasData && snapshot.data?.error?.error != ErrorType.requestTimedOut) {
                connected = true;
                ping.stop();
              }
              lastErrorType = snapshot.data?.error?.error;
              return fullPageLoadingSpinner(text: 'Connecting to the VPN...');
            } else {
              if (connected) {
                return MyPage();
              } else {
                return Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Center(child: Text(lastErrorType?.message ?? 'Couldn\'t connect to VPN')),
                  ],
                );
              }
            }
          },
        ),
    ...

This is what my log looks like:

Restarted application in 377ms. flutter: AsyncSnapshot<PingData>(ConnectionState.waiting, null, null, null) flutter: Ping on iOS is provided by the GBPing package modified by zuvola flutter: AsyncSnapshot<PingData>(ConnectionState.active, PingError(response:null, error:unknownHost), null, null) flutter: Ping on iOS is provided by the GBPing package modified by zuvola

I am definitely hitting ping.stop() as I've hit a breakpoint there. But ping.stream never closes the connection and returns a PingSummary.

point-source commented 1 year ago

Thanks for the ticket! I'll look into this next week