Optimal Location
When implementing virtual locations in your VPN service, you have two primary options for specifying the hop location: optimal location and custom location.
Optimal Location
The optimal location feature allows the VPN SDK to automatically select the best VPN server for your connection. This is ideal when you want to prioritize performance and let the system handle the routing decisions.
To use the optimal location in your code, you can utilize the VirtualLocation.optimal()
method. Here's an example of how to start a VPN connection with the optimal location:
To display the optimal location (country and city) for a user in your app's interface, you can retrieve this information from the credential
data returned by the Hydra SDK. Here's how to do it:
Please note that the connectedServerCountry
and connectedServerCity
properties will not be available before the connection is established, as the VPN SDK does not know which VPN server the backend will connect to as optimal. These properties can only be accessed after the connection has been made.
Virtual Locations
For users who require more control over their connection routing, the custom location option allows you to specify a particular intermediate server location.
Here's an example of finding a VPN connection with a custom location:
In this example, the intermediate hop is a server in San Jose, United States.
Optimal Location vs. Virtual Locations
It is important to note that Optimal location and Virtual locations are two separate features that can be configured independently. They offer flexibility in managing VPN connections but serve different purposes.
Optimal location is a feature that automatically selects VPN nodes based on predefined rules. These rules are designed to provide the best possible connection based on factors such as geographic proximity, server load, and network performance. In some cases, users may not have control over the predefined logic used by the Optimal location feature.
Virtual locations, on the other hand, refer to a list of locations that are made available to users. This list may not necessarily include all the VPN nodes that are available through the Optimal location feature. Virtual locations allow users to manually select specific locations from the provided list.
Optimal location and Virtual locations are two powerful features in VPN configuration that provide flexibility and control over how users connect to VPN nodes. While Optimal location automatically selects the best node based on predefined rules, Virtual locations allow users to manually choose from a specific list of locations.
Example Scenario
To better understand the difference between Optimal location and Virtual locations, consider the following example:
Suppose a VPN service provider wants to configure their system so that all users in the United States are automatically connected to VPN nodes located in the closest major cities with available data centers. These cities might include San Francisco, Boston, New York, Seattle, and others. This is where the Optimal location feature comes into play, automatically selecting the best node based on the user's location.
In addition to the Optimal location feature, the service provider wants to give each user the option to manually select from two specific Virtual locations: New York and Boston. In this case, the Virtual locations list will only contain these two locations, even though the Optimal location feature might connect users to nodes in other cities.
It's important to note that the Optimal location feature might return nodes that belong to a location not included in the Virtual locations list.
Last updated
Was this helpful?