Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Response/Socket Timeout Exceptions while scanning for VMs #2033

Closed
puneet101 opened this issue Mar 25, 2018 · 8 comments
Closed

Slow Response/Socket Timeout Exceptions while scanning for VMs #2033

puneet101 opened this issue Mar 25, 2018 · 8 comments

Comments

@puneet101
Copy link

We look at all the VMs on Azure using listByResourceGroup() and it's timing out with only ~80 VMs in the tenant:
PagedList vms = azureInstance.virtualMachines().listByResourceGroup(rg);

Questions:
#1
Is there a configurable timeout?

#2
What's the recommended approach to traverse through VMs when the tenant has 100's or 1000's of VMs.

We see this in our error logs:

Caused by: java.lang.RuntimeException: java.net.SocketTimeoutException: timeout
Mar 23 03:13:44 workspot-o1works1 app/worker.1: at rx.exceptions.Exceptions.propagate(Exceptions.java:58)
Mar 23 03:13:44 workspot-o1works1 app/worker.1: at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:464)
Mar 23 03:13:44 workspot-o1works1 app/worker.1: at rx.observables.BlockingObservable.single(BlockingObservable.java:341)
Mar 23 03:13:44 workspot-o1works1 app/worker.1: at com.microsoft.azure.management.compute.implementation.VirtualMachinesInner.list(VirtualMachinesInner.java:1441)

@puneet101
Copy link
Author

@anuchandy @anudeepsharma Let me know if you have any suggestions? Thanks!

@jianghaolu
Copy link
Contributor

When you initialize an Azure instance, you can configure the connection timeout:

Azure azure = Azure.configure()
                    .withConnectionTimeout(5, TimeUnit.MINUTES)
                    .authenticate(credFile)
                    .withDefaultSubscription();

@jianghaolu
Copy link
Contributor

jianghaolu commented Mar 27, 2018

To list VMs, there are 2 methods that does automatic paging:
1 - azure.virtualMachines().list() returns a PagedList<VirtualMachine> on which you should iterate through using a for loop. Any attempt to get its size will make numerous network calls and cache the entire list in the memory.
2 - Use Observables:

azure.virtualMachines().listAsync()
    .doOnNext(new Action1<VirtualMachine>() {
        @Override
        public void call(VirtualMachine virtualMachine) {
            
        }
    });

This will also automatically page through all the VMs and should only cache a page of VMs in the memory at a time.

@puneet101
Copy link
Author

Thanks @jianghaolu

@puneet101
Copy link
Author

.withConnectionTimeout(5, TimeUnit.MINUTES)
This doesn't work. We still get timed-out after one minute.

@menih
Copy link

menih commented Jul 18, 2018

We have the same issue. Increasing the timeout does not work. There is something fundamental changed recently that we started seeing it. It may go away for a bit and then it comes back.

@jianghaolu
Copy link
Contributor

There are 3 timeouts associated with the client, connection timeout, read timeout, and write timeout.

Currently we only expose configurations on connection timeout and read timeout and their default values are 10 seconds and 60 seconds respectively. This will give you a bit of a guess which one is timing out when you don't have a lot of other info.

You can configure them both on Azure.configure().

@praries880
Copy link
Contributor

Closing the issue, @puneet101 @menih kindly re-open the issue if you are still running into the tmeouts.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants