Agent disconnecting periodically

Hey all,
I have installed the recent LTS version of Jenkins in windows, I have connected two windows agent machines which has same configuration as my controller machine and same version of Java.

Now, my problem is agents are getting disconnected for every 7hours, even though jobs are running in it and getting connected back in few seconds.

I have connected the slaves through the batch command given in the agent page of Jenkins.

Jenkins setup:
Jenkins: 2.479.3
OS: Windows 10 - 10.0
Java: 17.0.9 - Azul Systems, Inc. (OpenJDK 64-Bit Server VM)

ant:511.v0a_a_1a_334f41b_
antisamy-markup-formatter:162.v0e6ec0fcfcf6
apache-httpcomponents-client-4-api:4.5.14-208.v438351942757
asm-api:9.7.1-97.v4cc844130d97
bootstrap5-api:5.3.3-1
bouncycastle-api:2.30.1.80-256.vf98926042a_9b_
branch-api:2.1208.vf528356feca_4
build-timeout:1.35
caffeine-api:3.1.8-133.v17b_1ff2e0599
checks-api:2.2.1
cloudbees-folder:6.980.v5a_cc0cb_25881
commons-lang3-api:3.17.0-84.vb_b_938040b_078
commons-text-api:1.13.0-153.v91dcd89e2a_22
credentials:1405.vb_cda_74a_f8974
credentials-binding:687.v619cb_15e923f
dark-theme:524.vd675b_22b_30cb_
display-url-api:2.209.v582ed814ff2f
durable-task:581.v299a_5609d767
echarts-api:5.5.1-5
eddsa-api:0.3.0-4.v84c6f0f4969e
email-ext:1876.v28d8d38315b_d
font-awesome-api:6.6.0-2
git:5.7.0
git-client:6.1.1
github:1.41.0
github-api:1.321-478.vc9ce627ce001
github-branch-source:1810.v913311241fa_9
gradle:2.14
gson-api:2.12.1-113.v347686d6729f
instance-identity:201.vd2a_b_5a_468a_a_6
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
jaxb:2.3.9-1
jjwt-api:0.11.5-112.ve82dfb_224b_a_d
joda-time-api:2.13.1-115.va_6b_5f8efb_1d8
jquery3-api:3.7.1-2
json-api:20250107-125.v28b_a_ffa_eb_f01
json-path-api:2.9.0-138.vc943da_d833b_6
junit:1312.v1a_235a_b_94a_31
ldap:776.vddf3e325103b_
mailer:489.vd4b_25144138f
matrix-auth:3.2.4
matrix-project:845.vffd7fa_f27555
metrics:4.2.21-461.v881e35d8fa_b_a_
mina-sshd-api-common:2.14.0-143.v2b_362fc39576
mina-sshd-api-core:2.14.0-143.v2b_362fc39576
okhttp-api:4.11.0-183.va_87fc7a_89810
pam-auth:1.11
pipeline-build-step:551.v178956c49ef8
pipeline-github-lib:61.v629f2cc41d83
pipeline-graph-analysis:216.vfd8b_ece330ca_
pipeline-graph-view:406.v06871361eb_2d
pipeline-groovy-lib:749.v70084559234a_
pipeline-input-step:508.v584c0e9a_2177
pipeline-milestone-step:119.vdfdc43fc3b_9a_
pipeline-model-api:2.2221.vc657003fb_d93
pipeline-model-definition:2.2221.vc657003fb_d93
pipeline-model-extensions:2.2221.vc657003fb_d93
pipeline-stage-step:312.v8cd10304c27a_
pipeline-stage-tags-metadata:2.2221.vc657003fb_d93
plain-credentials:183.va_de8f1dd5a_2b_
plugin-util-api:5.1.0
resource-disposer:0.25
scm-api:703.v72ff4b_259600
script-security:1369.v9b_98a_4e95b_2d
snakeyaml-api:2.3-123.v13484c65210a_
ssh-credentials:349.vb_8b_6b_9709f5b_
ssh-slaves:3.1021.va_cc11b_de26a_e
structs:338.v848422169819
theme-manager:278.v2e3c063e42cc
timestamper:1.28
token-macro:442.v4f452dc3c7c0
trilead-api:2.147.vb_73cc728a_32e
variant:70.va_d9f17f859e0
workflow-aggregator:600.vb_57cdd26fdd7
workflow-api:1363.v03f731255494
workflow-basic-steps:1079.vce64b_a_929c5a_
workflow-cps:4014.vcd7dc51d8b_30
workflow-durable-task-step:1405.v1fcd4a_d00096
workflow-job:1498.v33a_0c6f3a_4b_4
workflow-multibranch:800.v5f0a_a_660950e
workflow-scm-step:427.v4ca_6512e7df1
workflow-step-api:686.v603d058a_e148
workflow-support:944.v5a_859593b_98a_
ws-cleanup:0.48

I doubt this is a Jenkins problem. More likely related to your network that something is terminating the websocket after 7 hours.
PS: the term slave is deprecated please use agent instead

Thanks Markus!
I had tried with two versions of Jenkins, still disconnecting periodically.

  1. Is there any other way to connect to agent instead of websocket.?
  2. how to remove the timeout of 7hrs in network settings?
  3. or any other method is there to connect Jenkins, I had tried already with the windows service and running the command through cmd, still issue persists.
  1. you can try with ssh (the connection is initiated from the Jenkins controller) but it requires that you have the openssh properly configured on the agent machines. But there is no guarantee that you don’t run into the same problem with the timeout
  2. I don’t know where this timeout could be coming from but it is not Jenkins. Ask the responsibles for your network in your IT department

do you have some reverse proxy setup by chance?

No, I do not have any reverse proxy

netsh winhttp show proxy

Current WinHTTP proxy settings:

    Direct access (no proxy server).

I am facing this issue after migrating my Jenkins to other windows machine.