Add timeout features
Description
Many connections have the possibility of timing out. Some underlying libraries will drop a connection after a value they know about, but Train doesn't.
Train and Platform Version
1.4.38
Replication Case
First reported with long-running tests on Docker, which drops after 5 min. A long-running InSpec run (sleep 360 perhaps) should trigger it.
Possible Solutions
A better UX would be to add timeouts, retries, and keepalive options, which could be used as much as possible with underlying libraries.
Also consider a ping-like check to verify the connection is still alive.
I would really like to see that feature come to life. Would you maybe consider. to roughly guide me through the code (entrypoint to https://github.com/inspec/train/blob/master/lib/train/transports/docker.rb#L15) so that I could take a closer look?
This is an escalated issue from a customer, and will be added to the next sprint
This really comes down to whether the underlying connection library supports a timeout option. Timeouts are now supported in the SSH transport, the local transport for Unix and Windows Shell (non-Pipe) transports, and WinRM transports. So, this has been partially implemented.
For the docker transport to support timeouts, the docker-api gem would need to support a timeout option in the exec API call. It simply passes all options on to the docker engine API endpoint, which does not support any timeout options - https://docs.docker.com/engine/api/v1.41/#operation/ContainerExec .