Main node randomly disconnects from the slave node

Hi everyone,
Sometimes I have this issue, usually there’s no problem between communications between the main and agent nodes, however sometimes it happens that the connection gets dropped randomly.
Both nodes run on digitalocean, with main being 8cpus 16gb ram and the agent being 48cpu 96gb ram and it gets created before and deleted after the deployment process. It runs 13-15 jobs simultaneously and as I mentioned, most of the times it all goes fine. I managed to reproduce the event today and by inspecting the journal on the main node I managed to get the following piece of info that may be relevant:

Mar 21 14:03:23 devops-jenkins jenkins[228139]: 2025-03-21 14:03:23.110+0000 [id=965]        INFO        h.r.SynchronousCommandTransport$ReaderThread#run: I/O error in channel slave-node
Mar 21 14:03:23 devops-jenkins jenkins[228139]: java.io.StreamCorruptedException: invalid stream header: 636F7272
Mar 21 14:03:23 devops-jenkins jenkins[228139]:         at java.base/java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:958)
Mar 21 14:03:23 devops-jenkins jenkins[228139]:         at java.base/java.io.ObjectInputStream.<init>(ObjectInputStream.java:392)
Mar 21 14:03:23 devops-jenkins jenkins[228139]:         at hudson.remoting.ObjectInputStreamEx.<init>(ObjectInputStreamEx.java:49)
Mar 21 14:03:23 devops-jenkins jenkins[228139]:         at hudson.remoting.Command.readFrom(Command.java:142)
Mar 21 14:03:23 devops-jenkins jenkins[228139]:         at hudson.remoting.Command.readFrom(Command.java:128)
Mar 21 14:03:23 devops-jenkins jenkins[228139]:         at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:35)
Mar 21 14:03:23 devops-jenkins jenkins[228139]:         at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:61)

If you guys need any more info I’ll be glad to provide.

Main Node Jenkins setup:

Jenkins: 2.414.1
OS: Linux - 5.15.0-67-generic
Java: 17.0.14 - Ubuntu (OpenJDK 64-Bit Server VM)
---
ant:497.v94e7d9fffa_b_9
antisamy-markup-formatter:162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
bootstrap5-api:5.3.2-3
bouncycastle-api:2.30.1.78.1-233.vfdcdeb_0a_08a_a_
branch-api:2.1128.v717130d4f816
build-timeout:1.32
caffeine-api:3.1.8-133.v17b_1ff2e0599
checks-api:2.0.2
cloudbees-folder:6.858.v898218f3609d
command-launcher:107.v773860566e2e
commons-lang3-api:3.14.0-76.vda_5591261cfe
commons-text-api:1.11.0-108.v2c41b_8b_2b_269
credentials:1319.v7eb_51b_3a_c97b_
credentials-binding:642.v737c34dea_6c2
dashboard-view:2.495.v07e81500c3f2
display-url-api:2.204.vf6fddd8a_8b_e9
durable-task:555.v6802fe0f0b_82
echarts-api:5.4.0-7
email-ext:2.105
envinject:2.908.v66a_774b_31d93
envinject-api:1.199.v3ce31253ed13
font-awesome-api:6.5.1-2
git:5.2.1
git-client:4.6.0
github:1.37.3.1
github-api:1.318-461.v7a_c09c9fa_d63
github-branch-source:1771.v59b_6a_fa_1b_89e
gradle:2.12
gson-api:2.10.1-15.v0d99f670e0a_7
instance-identity:185.v303dc7c645f9
ionicons-api:74.v93d5eb_813d5f
jackson2-api:2.17.0-379.v02de8ec9f64c
jakarta-activation-api:2.1.3-1
jakarta-mail-api:2.1.3-1
javax-activation-api:1.2.0-7
javax-mail-api:1.6.2-10
jaxb:2.3.9-1
jdk-tool:73.vddf737284550
jjwt-api:0.11.5-112.ve82dfb_224b_a_d
jobConfigHistory:1229.v3039470161a_d
jquery3-api:3.7.1-1
jsch:0.2.16-86.v42e010d9484b_
json-api:20240205-27.va_007549e895c
json-path-api:2.9.0-33.v2527142f2e1d
junit:1265.v65b_14fa_f12f0
ldap:725.v3cb_b_711b_1a_ef
mailer:470.vc91f60c5d8e2
matrix-auth:3.2.2
matrix-project:822.824.v14451b_c0fd42
mina-sshd-api-common:2.12.1-101.v85b_e08b_780dd
mina-sshd-api-core:2.12.1-101.v85b_e08b_780dd
monitoring:1.99.0
naginator:1.448.vd1e2db_6902e3
okhttp-api:4.11.0-172.vda_da_1feeb_c6e
pam-auth:1.11
parameterized-trigger:787.v665fcf2a_830b_
pipeline-build-step:540.vb_e8849e1a_b_d8
pipeline-github-lib:61.v629f2cc41d83
pipeline-graph-analysis:216.vfd8b_ece330ca_
pipeline-groovy-lib:689.veec561a_dee13
pipeline-input-step:477.v339683a_8d55e
pipeline-milestone-step:119.vdfdc43fc3b_9a_
pipeline-model-api:2.2150.v4cfd8916915c
pipeline-model-definition:2.2150.v4cfd8916915c
pipeline-model-extensions:2.2150.v4cfd8916915c
pipeline-rest-api:2.34
pipeline-stage-step:312.v8cd10304c27a_
pipeline-stage-tags-metadata:2.2150.v4cfd8916915c
pipeline-stage-view:2.34
plain-credentials:182.v468b_97b_9dcb_8
plugin-util-api:3.8.0
postbuildscript:3.2.0-550.v88192b_d3e922
publish-over:0.22
publish-over-ssh:1.25
resource-disposer:0.23
scm-api:676.v886669a_199a_a_
script-security:1341.va_2819b_414686
snakeyaml-api:2.2-111.vc6598e30cc65
ssh-credentials:337.v395d2403ccd4
ssh-slaves:2.948.vb_8050d697fec
sshd:3.322.v159e91f6a_550
structs:325.vcb_307d2a_2782
timestamper:1.27
token-macro:400.v35420b_922dcb_
trilead-api:2.142.v748523a_76693
variant:60.v7290fc0eb_b_cd
workflow-aggregator:600.vb_57cdd26fdd7
workflow-api:1291.v51fd2a_625da_7
workflow-basic-steps:1058.vcb_fc1e3a_21a_9
workflow-cps:3837.v305192405b_c0
workflow-durable-task-step:1331.vc8c2fed35334
workflow-job:1385.vb_58b_86ea_fff1
workflow-multibranch:770.v1a_d0708dd1f6
workflow-scm-step:427.v4ca_6512e7df1
workflow-step-api:639.v6eca_cd8c04a_a_
workflow-support:907.v6713a_ed8a_573
ws-cleanup:0.46

Could you check the java version on the agent before and after the job fails? Sometimes auto updates on java can cause the connection to fail. This can be solved by disabling auto-update on the java.

Thank you for the reply, I’ll give it a try today and let you know

EDIT: I did have automatic updates/upgrades switched on in 20auto-upgrades, when apt update/upgrade was used there was a jdk under the “the following packages will be upgraded…”, when I checked back the main jenkins node I saw that it lost the connection to the agent. Chances are very high that the upgrades were the reason for connection drops. I will test this out more after updating packages and disabling automatic upgrades and will let you know if the connection keeps dropping again.

I hope you were able to disable auto updates. If not check these two out:
disable automatic updates on ubuntu
how to prevent updating of a specific package