eduvpn/macos

state issue

efef opened this issue · 8 comments

efef commented

sometimes the app gets in wrong state. For example back button not working. One example which is easy to generate:

-connect the VPN, wait till icon is 'green' and click immediately 'disconnect'
-when icon turn 'red' immediately click 'connect'
-the app will strangely disconnect within a second (bug)
-immediately click 'connect', the app wil provide an error like 'request timed out' or complain about helper app or after some some seconds disconnect. (bug)

efef commented

other example sometimes the app doesn't trigger a re-login flow when oauth token is revoked in webinterface.
Steps to reproduce:
-connect the VPN - icon is green
-go to webinterface - account and click 'revoke' eduVPN for MacOS
-wait a random time before click 'disconnect'.
-wait till icon is red and click 'connect'.
Sometimes the re-authentication via browser starts (good), but sometimes the eduVPN client tries to connect the VPN session (bug)

@efef , working on that

While disconnecting updateForStateChange() is being called for three times, in connectionViewController.swift

commenting out in ConnectionService.swift works for me

    helper.close {
        self.configURL = nil
        self.twoFactor = nil
        self.handler = nil
        self.closeManagingSocket(force: false)
      //self.state = .disconnected
        handler(.success(Void()))
    }

Solution for

sometimes the app gets in wrong state. For example back button not working. One example which is easy to generate:

-connect the VPN, wait till icon is 'green' and click immediately 'disconnect'
-when icon turn 'red' immediately click 'connect'
-the app will strangely disconnect within a second (bug)
-immediately click 'connect', the app wil provide an error like 'request timed out' or complain about helper app or after some some seconds disconnect. (bug)

@theNerdFromSiliconValley That code in your comment is from an old version. I had added a cool down period:

        helper.close {
            self.configURL = nil
            self.twoFactor = nil
            self.handler = nil
            self.closeManagingSocket(force: false)
            self.coolDown(handler)
        }

@efef Try not to report multiple issues in the same ticket, but also not to report the same issue multiple times. This #184 (comment) is the same as new issue reported at the bottom of #135

@johankool , I got it now. After disconnecting the bug happens because for a short period of time to state stay as unexpectedState

@johankool Why you have put 6 sec here, instead of any other number?

    DispatchQueue.main.asyncAfter(deadline: .now() + 6.0) {
        self.state = .disconnected
        handler?(.success(Void()))
    }

@johankool When someone is disconnecting the VPN, if it is disconnected within 6 sec, that is fine. No issues. But if it is not disconnected withing 6 sec, then the issue becomes visible.

extension ConnectionService: ClientProtocol {

func taskTerminated(reply: @escaping () -> Void) {
    state = .disconnecting
    reply()
    coolDown()
    configURL = nil
    handler = nil
}

}

This is being called two times while disconnecting, so cooldown command is being called two times. But we need to call it once, best is if we can avoid cooling time hardcoding