Reconnection strategy
The SDK provides automatic network reconnection handling when the user switches between networks. This document outlines the reconnection logic and how to configure the SDK's reconnection behavior.
Default Reconnection Behavior
By default, the SDK will automatically handle network reconnection when the user switches between networks. The SDK's behavior in different scenarios is as follows:
VPN ON and Network Connection Disabled
If VPN is ON and the user disables the network connection, the SDK transfers to the PAUSED state.
After the network connection is re-enabled, the SDK automatically connects to the last successful configuration.
Transport Error During Connection
If a transport error occurs during connection, the SDK will attempt to reconnect automatically.
However, there are certain exceptions where automatic reconnection will not occur:
CODE_NOT_AUTHORIZED
The user is not authorized. In this case, you need to call HydraSdk.login
to re-authenticate.
CODE_SESSIONS_EXCEED
The session limit is reached in accordance with the Terms of Service (ToS).
CODE_DEVICES_EXCEED
The devices limit is reached in accordance with the ToS.
CODE_OAUTH_ERROR
An authentication error occurred on the OAuth server.
CODE_TRAFFIC_EXCEED
The traffic limit is exceeded in accordance with the ToS.
USER_SUSPENDED
The user account is suspended.
Disabling Automatic Reconnection
To disable the automatic reconnection behavior, you can use the following method:
By calling setReconnectionEnabled(false)
, the SDK will not attempt to reconnect automatically when network switches occur or transport errors happen. You will need to handle reconnection manually in your application logic.
Last updated