openvpn_flutter icon indicating copy to clipboard operation
openvpn_flutter copied to clipboard

Await Future in method "disconnect"

Open YukiAttano opened this issue 2 years ago • 2 comments

The invokeMethod("disconnect") call is not awaited. Which seems to throw if no connection is running and the method gets called. This Exception can't be catched because disconnect() does not await the invokeMethod() call.

  ///Disconnect from VPN
  void disconnect() {
    _tempDateTime = null;
    _channelControl.invokeMethod("disconnect");
    if (_vpnStatusTimer?.isActive ?? false) {
      _vpnStatusTimer?.cancel();
      _vpnStatusTimer = null;
    }
  }

YukiAttano avatar Feb 01 '24 09:02 YukiAttano

I'm getting sometime:

E/flutter ( 5968): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'void de.blinkt.openvpn.core.OpenVPNService.openvpnStopped()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'void de.blinkt.openvpn.core.OpenVPNService.openvpnStopped()' on a null object reference

bugrevealingbme avatar Jul 16 '24 14:07 bugrevealingbme