Jump to content
Welcome to our new Citrix community!
  • 0

Android: Session Expired

Galina Borodulina



How to work with session expired error?


I do all like said in docs, but it still showing error:


In my ViewModel i'm starting tunnel:

 init {

    private fun startTunnel() {
        startTunnelUseCase.execute(object : TunnelHandler {
            override fun onStartTunnelSuccess() {

            override fun onDebug(code: ResponseStatusCode) {
            override fun onSessionExpired() {

            override fun tunnelAlreadyRunning() {


If i got session expired, i just trying to refresh it and starting tunnel again.

What i am doing in StartTunnelUseCase:

1) Stopping existing tunnel (try-catch block)

2) Removing all existing callbacks from Handler (try-catch block)

3) Starting new tunnel with new callback (under try-catch block)

class StartTunnelUseCase @Inject constructor(@ApplicationContext private val context: Context) :
    UseCase<Unit, TunnelHandler>() {

    override fun execute(parameters: TunnelHandler?) {
        try {
        } catch (e: Exception) {


        parameters?.let {
            val messanger = Messenger(object : Handler(Looper.getMainLooper()) {
                override fun handleMessage(msg: Message) {
                    when (fromId(msg.what)) {
                        START_TUNNEL_SUCCESS -> it.onStartTunnelSuccess()
                        START_TUNNEL_FAILED -> it.onStartTunnelFailed()
                        TUNNEL_ALREADY_RUNNING -> it.tunnelAlreadyRunning()
                        SESSION_EXPIRED -> it.onSessionExpired()
                        FOUND_LEGACY_MODE -> it.onLegacyModeFound()
                        FOUND_NON_WEBSSO_MODE -> it.onNonWebSsoModeFound()
                        FOUND_NON_MANAGED_APP -> it.onNonManagedApp()
                        NO_NETWORK_CONNECTION -> it.onNoNetworkConnection()
                        INVALID_APP_CONFIGURATION_DATA -> it.onInvalidAppConfiguration()
                        INVALID_OAUTH_TOKEN -> it.onInvalidOAuthToken()
                        else -> it.onUnknownError()

            MicroVPNSDK.startTunnel(context, messanger)


It just always show SESSION_EXPIRED error and i can't beat it

Link to comment

1 answer to this question

Recommended Posts

  • 0

SESSION_EXPIRED error code is returned when MAM SDK fails to establish a valid session with Gateway or if Gateway session is expired.


Could you please check the below things?


1. MDX file corresponding to the APK file is published to CEM Console

2. Secure Hub is enrolled successfully


If you are still getting the same error, we will need to look at the logs to debug further.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...