After connecting jenkins agent to jenkins controller, connection is broken after a few hours

After connecting jenkins agent to jenkins controller, connection is broken after a few hours.

I want to be able to keep the connection.
I would like to resolve the following error.
If anyone can give me some advice and how to solve this problem, I would appreciate it.

 9月 04, 2022 5:05:11 午後 io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.ClientFilter processError
 重大: Connection error has occurred
 java.io.IOException: Connection reset by peer
  1. Environment
    ・Jenkins Controller OS: Amazon Linux II
    ・Jenkins Core Version: 2.346.3
    ・Jenkins Agent OS: Mac OS X 12.4
    ・Jenkins Agent Version: Unix agent, version 4.13.3

  2. Mac OS terminal execution log

Last login: Sat Sep 3 10:00:29 on ttys000
 /Users/{user-name}/Jenkins/start-up-jenkins.command ; exit;
 {user-name}@{node-name} ~ % /Users/{user-name}/Jenkins/start-up-jenkins.command ; exit;
 9月 04, 2022 8:15:09 午前 org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
 情報: Using /Users/{user-name}/Jenkins/remoting as a remoting work directory
 9月 04, 2022 8:15:09 午前 org.jenkinsci.remoting.engine.WorkDirManager setupLogging
 情報: Both error and output logs will be printed to /Users/{user-name}/Jenkins/remoting
 9月 04, 2022 8:15:10 午前 hudson.remoting.jnlp.Main createEngine
 情報: Setting up agent: {node-name}
 9月 04, 2022 8:15:10 午前 hudson.remoting.jnlp.Main$CuiListener <init>
 情報: Jenkins agent is running in headless mode.
 9月 04, 2022 8:15:10 午前 hudson.remoting.Engine startEngine
 情報: Using Remoting version: 4.13.3
 9月 04, 2022 8:15:10 午前 org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
 情報: Using /Users/{user-name}/Jenkins/remoting as a remoting work directory
 9月 04, 2022 8:15:10 午前 hudson.remoting.jnlp.Main$CuiListener status
 情報: WebSocket connection open
 9月 04, 2022 8:15:10 午前 hudson.remoting.jnlp.Main$CuiListener status
 情報: Connected


 9月 04, 2022 5:05:11 午後 io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.ClientFilter processError
 重大: Connection error has occurred
 java.io.IOException: Connection reset by peer
     at java.base/sun.nio.ch.FileDispatcherImpl.read0(Native Method)
     at java.base/sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
     at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
     at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:245)
     at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:223)
     at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishRead(UnixAsynchronousSocketChannelImpl.java:395)
     at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:191)
     at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)
     at java.base/sun.nio.ch.KQueuePort$EventHandlerTask.run(KQueuePort.java:312)
     at java.base/java.lang.Thread.run(Thread.java:834)
 9月 04, 2022 5:05:11 午後 hudson.remoting.jnlp.Main$CuiListener status
 情報: Read side closed
 9月 04, 2022 5:05:11 午後 hudson.remoting.jnlp.Main$CuiListener status
 情報: Terminated
 
 
 9月 04, 2022 5:05:11 午後 hudson.remoting.jnlp.Main$CuiListener status
 情報: Performing onReconnect operation.
 9月 04, 2022 5:05:11 午後 jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$EngineListenerAdapterImpl onReconnect
 情報: Restarting agent via jenkins.slaves.restarter.UnixSlaveRestarter@183387f0
 /Users/{user-name}/Jenkins/start-up-jenkins.command: line 1: 26440 Killed: 9        java -jar /Users/{user-name}/Jenkins/agent.jar -jnlpUrl https://{jenkins-url}/computer/{node-name}/jenkins-agent.jnlp -secret {secret} -workDir "/Users/{user-name}/Jenkins"
 Saving session...
 ...copying shared history...
 ...saving history...truncating history files...
 ...completed.
 [プロセスが完了しました]
  1. slave.log after output of execution log for Mac OS terminals
[{user-name}@ip-**** {node-name}]# cat slave.log
 Inbound agent connected from ****
 Remoting version: 4.13.3
 Launcher: JNLPLauncher
 Communication Protocol: WebSocket
 This is a Unix agent
 Agent successfully connected and online
 ERROR: Connection terminated
 java.nio.channels.ClosedChannelException
     at jenkins.agents.WebSocketAgents$Session.closed(WebSocketAgents.java:153)
     at jenkins.websocket.WebSocketSession.onWebSocketSomething(WebSocketSession.java:92)
     at com.sun.proxy.$Proxy75.onWebSocketClose(Unknown Source)
     at org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver.onClose(JettyListenerEventDriver.java:149)
     at org.eclipse.jetty.websocket.common.WebSocketSession.callApplicationOnClose(WebSocketSession.java:394)
     at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.disconnect(AbstractWebSocketConnection.java:316)
     at org.eclipse.jetty.websocket.common.io.DisconnectCallback.failed(DisconnectCallback.java:36)
     at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.close(AbstractWebSocketConnection.java:197)
     at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:510)
     at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:440)
     at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
     at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
     at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
     at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)
     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
     at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
     at java.base/java.lang.Thread.run(Thread.java:829)
  1. Message from mail-watcher-plugin
Initiator: SYSTEM Url: https://{jenkins-url}/computer/{node-name}/Connection was broken: java.util.concurrent.TimeoutException: Ping started at 1662278711466 hasn't completed by 1662278951467
 at hudson.remoting.PingThread.ping(PingThread.java:132)
 at hudson.remoting.PingThread.run(PingThread.java:88)

Lots of things could happen between your agents and your controller…
Is there a firewall on your agent machines? How is the network configured on the Amazon machine?
Is your Mac at home? Does your ISP accept long-running connections?
Was it working before you moved to Jenkins 2.346.3? If so, what version were you running beforehands?
Did you recently change your Java version?

My $0.02.