Agents on EC2 keep disconnecting


I am using the AWS EC2 plugin to manage EC2 build agents. I have it set up to have a max of 2 agents with 3 build executors each. When everything is working, it works great. However, I frequently have to delete agents and spin up new ones because they randomly get disconnected.

Mar 28, 2024 4:06:54 PM INFO hudson.slaves.ChannelPinger$1 onDead

Ping failed. Terminating the channel EC2 (AWS EC2) - Jenkins Build Agent (i-hjkfsdjkhfhjksdfhjklsdfhjklsdf).
java.util.concurrent.TimeoutException: Ping started at 1711641774055 hasn't completed by 1711642014056

Mar 28, 2024 4:06:57 PM INFO hudson.remoting.Request$2 run

Failed to send back a reply to the request UserRequest:hudson.remoting.PingThread$Ping@7dc462f: hudson.remoting.ChannelClosedException: Channel "hudson.remoting.Channel@48ccf531:EC2 (AWS EC2) - Jenkins Build Agent (i-jhksdfhjksdfhjklsdfhjkl)": channel is already closed

I’ve tried “Connect by SSH process” and without. I’ve tried allowing ICMP via the security group. I’ve tried connect by IP and connect by DNS name. All this and it still persists. I’ve even set jenkins.ec2.bootstrapAuthSleepMs and jenkins.ec2.bootstrapAuthTries to 30000 and 30, respectively, according to another post I saw, and it hasn’t helped.

Are there any other settings I can change or things I can check to see what the problem is?

I am on 2.440.2 btw, and my controller is also running in EC2.