diff --git a/CHANGELOG.md b/CHANGELOG.md index de8fd4f72..1369d1c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ BUG FIXES: + - core: Fix cases where sometimes SSH connection would hang. - providers/docker: Create args works. [GH-4526] - providers/virtualbox: Show a human-friendly error if VirtualBox didn't clean up an existing VM. [GH-4681] diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index f4d152002..516639148 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -265,8 +265,13 @@ module VagrantPlugins # There is a chance that the socket is closed despite us checking # 'closed?' above. To test this we need to send data through the # socket. + # + # We wrap the check itself in a 5 second timeout because there + # are some cases where this will just hang. begin - @connection.exec!("") + Timeout.timeout(5) do + @connection.exec!("") + end rescue Exception => e @logger.info("Connection errored, not re-using. Will reconnect.") @logger.debug(e.inspect)