Windows WebSocket agents frequently looses connection to jenkins

Hello, I am facing problems regarding the connectivity of the Jenkins agent with the main Jankins server.
Configuration:
We have Jenkins server installed in Azure. It works through the Azure Application Gateway, which forwards connections from 8080 to 443 and allows websocket connections with a default timeout of 20 seconds.
We would like to connect Jenkins node that is not located in Azure to this Jenkins server using websocket.

When we have the default “Request time-out (seconds)” set to 20 seconds on Application Gateway, we get the following log and connection termination:

INFO: Using \tmp\jenkins\remoting as a remoting work directory
Apr 04, 2024 12:24:59 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to \tmp\jenkins\remoting
Apr 04, 2024 12:24:59 PM hudson.remoting.Launcher createEngine
INFO: Setting up agent: test
Apr 04, 2024 12:24:59 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 3206.vb_15dcf73f6a_9
Apr 04, 2024 12:24:59 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using \tmp\jenkins\remoting as a remoting work directory
Apr 04, 2024 12:24:59 PM hudson.remoting.Launcher$CuiListener status
INFO: WebSocket connection open
Apr 04, 2024 12:24:59 PM hudson.remoting.Launcher$CuiListener status
INFO: Connected
Apr 04, 2024 12:25:34 PM hudson.remoting.Launcher$CuiListener status
INFO: Read side closed
Apr 04, 2024 12:25:34 PM hudson.remoting.Launcher$CuiListener status
INFO: Terminated
Apr 04, 2024 12:25:45 PM hudson.remoting.Launcher$CuiListener status
INFO: Performing onReconnect operation.
Apr 04, 2024 12:25:45 PM hudson.remoting.Launcher$CuiListener status
INFO: onReconnect operation completed.
Apr 04, 2024 12:25:45 PM hudson.remoting.Launcher$CuiListener status
INFO: WebSocket connection open
Apr 04, 2024 12:25:45 PM hudson.remoting.Launcher$CuiListener status
INFO: Connected
Apr 04, 2024 12:26:20 PM hudson.remoting.Launcher$CuiListener status
INFO: Read side closed
Apr 04, 2024 12:26:20 PM hudson.remoting.Launcher$CuiListener status
INFO: Terminated

When we set this time to a larger number of seconds, it works for only that specific time, and then it interrupts again. But even setting the maximum time to 86400 seconds is not enough since it should work without interruptions.
The command we are using is:

curl.exe -sO https://domainname/jnlpJars/agent.jar
java -jar agent.jar -url https://domainname -secret secret -name test -workDir "/tmp/jenkins" -webSocket

Is there something we can do to make jenkins agent never looses the network connectivity even for a very short time? This is causing a lot of sporadic instabilities to the jobs that are running in the agents.

Jenkins setup:
Jenkins: 2.440.2
OS: Linux - 6.2.0-1019-azure
Java: 17.0.10 - Private Build (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
asm-api:9.6-3.v2e1fa_b_338cd7
authentication-tokens:1.53.v1c90fd9191a_b_
azure-ad:457.vf85d61f83b_26
azure-artifact-manager:154.vb6e2724f0095
azure-container-agents:253.vd2f5cd5c5040
azure-credentials:312.v0f3973cd1e59
azure-keyvault:237.v301692369180
azure-sdk:157.v855da_0b_eb_dc2
azure-vm-agents:901.ved986df424b_3
blueocean-commons:1.27.11
blueocean-rest:1.27.11
bootstrap5-api:5.3.3-1
bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9
branch-api:2.1152.v6f101e97dd77
build-timeout:1.32
caffeine-api:3.1.8-133.v17b_1ff2e0599
checks-api:2.0.2
cloud-stats:336.v788e4055508b_
cloudbees-folder:6.901.vb_4c7a_da_75da_3
command-launcher:107.v773860566e2e
commons-lang3-api:3.13.0-62.v7d18e55f51e2
commons-text-api:1.11.0-95.v22a_d30ee5d36
copyartifact:722.v0662a_9b_e22a_c
credentials:1337.v60b_d7b_c7b_c9f
credentials-binding:657.v2b_19db_7d6e6d
customizable-header:83.vf51a_828deb_b_e
dashboard-view:2.508.va_74654f026d1
display-url-api:2.200.vb_9327d658781
docker-commons:439.va_3cb_0a_6a_fb_29
dtkit-api:3.0.2
durable-task:550.v0930093c4b_a_6
echarts-api:5.5.0-1
email-ext:2.105
extra-columns:1.26
font-awesome-api:6.5.1-3
gerrit-checks-api:66.v3ef8b_f08f1f3
gerrit-code-review:0.4.9
gerrit-trigger:2.40.0
gerrit-verify-status-reporter:0.0.3
git:5.2.1
git-client:4.7.0
github:1.38.0
github-api:1.318-461.v7a_c09c9fa_d63
github-branch-source:1785.v99802b_69816c
gradle:2.10
gson-api:2.10.1-15.v0d99f670e0a_7
http_request:1.18
instance-identity:185.v303dc7c645f9
ionicons-api:56.v1b_1c8c49374e
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-6
javax-mail-api:1.6.2-9
jaxb:2.3.9-1
jdk-tool:73.vddf737284550
jjwt-api:0.11.5-77.v646c772fddb_0
joda-time-api:2.12.7-29.v5a_b_e3a_82269a_
jquery3-api:3.7.1-2
jsch:0.2.16-86.v42e010d9484b_
json-api:20240303-41.v94e11e6de726
json-path-api:2.9.0-58.v62e3e85b_a_655
junit:1265.v65b_14fa_f12f0
ldap:719.vcb_d039b_77d0d
lucene-search:408.v0fb_8d1093c83
mailer:472.vf7c289a_4b_420
matrix-auth:3.2.2
matrix-project:822.824.v14451b_c0fd42
mina-sshd-api-common:2.12.0-99.vdb_f07841c2db_
mina-sshd-api-core:2.12.0-99.vdb_f07841c2db_
oic-auth:4.225.v03326773b_44b_
okhttp-api:4.11.0-172.vda_da_1feeb_c6e
pam-auth:1.10
pipeline-build-step:540.vb_e8849e1a_b_d8
pipeline-github-lib:42.v0739460cda_c4
pipeline-graph-analysis:216.vfd8b_ece330ca_
pipeline-groovy-lib:704.vc58b_8890a_384
pipeline-input-step:491.vb_07d21da_1a_fb_
pipeline-milestone-step:111.v449306f708b_7
pipeline-model-api:2.2184.v0b_358b_953e69
pipeline-model-definition:2.2184.v0b_358b_953e69
pipeline-model-extensions:2.2184.v0b_358b_953e69
pipeline-rest-api:2.34
pipeline-stage-step:305.ve96d0205c1c6
pipeline-stage-tags-metadata:2.2184.v0b_358b_953e69
pipeline-stage-view:2.34
plain-credentials:179.vc5cb_98f6db_38
plugin-util-api:4.1.0
project-build-times:1.2.1
resource-disposer:0.23
role-strategy:713.vb_3837801b_8cc
saferestart:0.7
saml:4.464.vea_cb_75d7f5e0
scm-api:689.v237b_6d3a_ef7f
script-security:1326.vdb_c154de8669
simple-theme-plugin:176.v39740c03a_a_f5
snakeyaml-api:2.2-111.vc6598e30cc65
sonar:2.17.2
sonar-gerrit:385.v890738eeff15
ssh-agent:346.vda_a_c4f2c8e50
ssh-credentials:326.v7fcb_a_ef6194b_
ssh-slaves:2.948.vb_8050d697fec
sshd:3.322.v159e91f6a_550
structs:337.v1b_04ea_4df7c8
timestamper:1.26
token-macro:400.v35420b_922dcb_
trilead-api:2.142.v748523a_76693
variant:60.v7290fc0eb_b_cd
windows-azure-storage:419.v4046cd70d2e3
workflow-aggregator:596.v8c21c963d92d
workflow-api:1291.v51fd2a_625da_7
workflow-basic-steps:1049.v257a_e6b_30fb_d
workflow-cps:3889.v937e0b_3412d3
workflow-durable-task-step:1331.vc8c2fed35334
workflow-job:1400.v7fd111b_ec82f
workflow-multibranch:773.vc4fe1378f1d5
workflow-scm-step:427.v4ca_6512e7df1
workflow-step-api:657.v03b_e8115821b_
workflow-support:881.v7663695646cf
ws-cleanup:0.45
xunit:3.1.4