After an SSH connection is set up through VS Code, no operation is performed for a long time and the window retains open. When the connection is used again, it is found that the connection is disconnected and no error message is displayed.
According to VS Code Remote-SSH logs, the connection was disconnected about two hours after the setup.
After SSH interaction stops for a period of time, the firewall disconnects idle connections (http://bluebiu.com/blog/linux-ssh-session-alive.html). The default SSH configuration does not lead to a proactive disconnection upon timeout. Since the instance runs stably on the backend, set up the connection again to resolve this issue.
To retain connections if no operation is performed for a long time, configure periodic message sending through SSH. In this way, the connection will not become idle on the firewall.
The configuration is as follows:
Host ModelArts-xx ... ServerAliveInterval 3600 # Add this configuration in the unit of second, indicating that the client will actively send a heartbeat packet to the server every hour. ServerAliveCountMax 3 # Add this configuration, indicating that if the server does not respond after the heartbeat packet is sent for three times, the connection will be disconnected.
For example, if the firewall is configured to disconnect a connection if the connection is idle for two hours, set ServerAliveInterval to a value less than two hours (for example, one hour) on the client to prevent the firewall from disconnecting the connection.
The preceding configuration shows that the server actively sends a heartbeat packet to the client every 24 hours, and the connection will be disconnected if the client does not respond after the heartbeat packet is sent for three times.
For details, see https://unix.stackexchange.com/questions/3026/what-do-options-serveraliveinterval-and-clientaliveinterval-in-sshd-config-d.
nohup train.sh > output.log 2>&1 & tail -f output.log