Winrm error "Blocking operation timed out!"

Hi,

I’m trying to bring up a test AD server on Windows 2019 guest using Hyper-V. I’ve run the provision such that:

  1. setup AD
  2. vagrant plugin reload
  3. Perform post-AD configuration

During the provisioning, I can see from the log that:

  1. vagrant set hostname
  2. runs the 1st provision (that is setup AD)
  3. reboot
  4. set hostname. This is where I hit the error below:

==> kerberos: Waiting for machine to boot. This may take a few minutes…
kerberos: WinRM address: 172.17.20.228:5985
kerberos: WinRM username: vagrant
kerberos: WinRM execution_time_limit: PT2H
kerberos: WinRM transport: plaintext
An error occurred executing a remote WinRM command.

Shell: Cmd
Command: hostname
Message: Blocking operation timed out!

Note that I can see that after the reboot, the guest system is showing “Applying computer setttings” for some time before completing and showing the logon prompt.

I’ve tried to set winrm.timeout, winrm.max_retries, winrm.retry_delay to be beyond the time the system “Applying computer settings”. However, it seems that winrm indeed can connect just that it got the error response.

Is there any way that winrm can wait / retry until there is no “blocking operation”?

Ended up I added a workaround. Not ideal as it keeps on waiting for every reboot, but at least it will wait for Windows to complete applying computer settings.

config.trigger.before :“VagrantPlugins::HyperV::Action::WaitForIPAddress”, type: :action do |t|
t.info = “Sleep to prevent issues where Windows hasn’t completed Applying computer settings”
t.run = { inline: “Start-Sleep -Seconds 180” }
end

I am affected by the same issue. It seems with 2.4.2 (or .3?) the winrm gem.
The problem raised by winrm should be caught by the retry logic.

Would you be willing to create a Github issue for this?