I want to control the timeout, connection retries number and the delay duration between the retries when the connection to the Azure NetworkManager failed.
Here is how I connect to Azure:
private void connect() {
HttpClient httpClient = HttpClient.createDefault();
TokenCredential tokenCredential = new ClientSecretCredentialBuilder()
.clientSecret(azureCredentials.getDecryptedDeviceLoginPassword())
.clientId(azureCredentials.getDeviceLoginUsername())
.tenantId(tenantId)
.httpClient(httpClient)
.build();
AzureProfile azureProfile = new AzureProfile(...)
NetworkManager.Configurable configurable = NetworkManager.configure().withLogLevel(HttpLogDetailLevel.BODY).withHttpClient(httpClient);
NetworkManager networkManager = configurable.authenticate(tokenCredential, azureProfile);
networkManager.resourceManager().providers().getByName("Microsoft.Compute");
}
When the connection failed there are 3 connection attempts and also delay between each retry.
how can I configure custom timeout, retries and delay between the attempts?
I tried to configure RetryPolicy as the following:
RetryStrategy retryStrategy = getRetryStrategy();
RetryPolicy retryPolicy = new RetryPolicy(retryStrategy);
private RetryStrategy getRetryStrategy() {
return new RetryStrategy() {
@Override
public int getMaxRetries() {
return 1;
}
@Override
public Duration calculateRetryDelay(int retryAttempts) {
return Duration.ofSeconds(2);
}
};
}
and use it on the networkManager configureation but I still have long delay between the connection attempts.