Why did my session disconnect?
How to tell why a terminal session ended, from idle timers and host sign-off to a network change, sleep, SSH keep-alives, Mosh, or a TLS handshake failure.
A session can end for several different reasons. The right next step depends on whether a screen ever appeared, whether you had been idle, and whether the network or the device changed.
If no screen ever appeared
The connection failed while it was starting. That is not the same as a drop later.
- A refused or timed-out TCP connection, or a banner-exchange error on SSH, means login never completed. See Connection abort, reset and timed-out errors in SSH and Telnet clients and SSH error messages, what each one means.
- A TLS handshake failure on a secure 3270 port is logged on z/OS as
EZZ6034I CONN DROP ERR 6002. It happens before any LU is assigned, so the client never gets a screen. See EZZ6034I CONN DROP ERR 6002, TN3270 TLS handshake failed and TLS for 3270 and 5250.
If it dropped while you were idle
Two different timers can look the same from your side.
A network device ended a quiet connection. Firewalls and NAT boxes often close a TCP session that has had no traffic for a while. On z/OS, the TN3270 server then logs EZZ6034I with reason ERR 1027 (no TCP acknowledgement), TIMEMARK (no reply to the server's "are you there" request), or CLNTDISC (the client end closed, which is also what you see when a firewall sends a reset). IBM documents that the TN3270 server does not use TCP keep-alive. It uses TIMEMARK and SCANINTERVAL instead. See EZZ6034I CONN DROP after idle, TN3270 TIMEMARK and SCANINTERVAL.
The host signed you off. These timers watch your work, not the packets that keep a firewall happy:
- z/OS TN3270
INACTIVE. It counts SNA traffic between Telnet and VTAM, so keep-alive traffic from the client does not reset it. The drop is logged as INACT-S. See EZZ6034I CONN DROP after idle, TN3270 TIMEMARK and SCANINTERVAL. - TSO JWT, the SMF job wait time. It cancels an idle TSO address space, so there is nothing to reconnect to. A session that was only disconnected, rather than cancelled, is kept for RECONLIM minutes (IBM's default is 3) and JWT does not cancel it. See Reconnect to a TSO session after the connection drops.
- IBM i
QINACTITV. After the inactive interval (5 to 300 minutes, or*NONEto leave it off),QINACTMSGQends the job, disconnects it, or sends message CPI1126. Telnet sessions that use automaticQPADEVxxxxdevice names often cannot be disconnected and are ended instead. See Why an IBM i session ends or signs off when it sits idle.
Some clients send keep-alive traffic so a quiet connection is less likely to be dropped by a firewall. That does not stop a host timer that watches your work. See Why a session disconnects when it sits idle.
If the network changed, or a device went to sleep
SSH and Telnet bind the session to one TCP connection. If the device changes from Wi-Fi to cellular, a VPN reconnects, or the phone, tablet or host goes to sleep, that connection is usually gone.
- The SSH client may print "client_loop: send disconnect: Broken pipe" when it next tries to write, or "Software caused connection abort" or "Connection reset by peer". See SSH "client_loop: send disconnect: Broken pipe" and Connection abort, reset and timed-out errors in SSH and Telnet clients.
- If the host is a Mac, a sleeping Mac or a closed laptop lid stops answering. See SSH to a Mac from a phone or tablet, Remote Login and sleep.
- If the session ended while the client was in the background, see Background sessions.
SSH keep-alives
OpenSSH can send alive messages inside the encrypted channel: ServerAliveInterval on the client, ClientAliveInterval on the server. If the other side does not answer after CountMax messages (the default is 3), the sender closes the session. The interval defaults to 0, which means no messages are sent.
These detect a dead connection. They cannot restore one, and they cannot stop a firewall from cutting the path. If the link is already gone, a short interval only makes the session end sooner. When the client gives up this way, it prints "Timeout, server ... not responding." See SSH keep-alives and idle timeouts.
Mosh, compared with SSH
A Mosh session is built to survive a change of IP address, a sleep, or a lost signal. The client logs in over SSH, then the session itself runs over UDP. By default mosh-server waits for the client with no time limit. A host can set MOSH_SERVER_NETWORK_TMOUT so the server exits after that many seconds with no update from the client. That is a connectivity timeout, not an idle-work timeout.
Starting Mosh again starts a new session. It does not reattach to an old mosh-server. See Mosh or SSH?, How Mosh works, How long a Mosh session lasts and You have a detached Mosh session on this server.
Getting work back
- TSO on z/OS. If the address space is still waiting, log on again with RECONNECT within RECONLIM. See Reconnect to a TSO session after the connection drops.
- z/VM. Log on again with
LOGON user1 HEREbefore the site's grace period ends. See z/VM HCPLGA054E "Already logged on": reconnect with LOGON ... HERE. - IBM i. A disconnected job can be picked up only if you use the same device name. If the job was ended, unsaved work in that job is gone. See Why an IBM i session ends or signs off when it sits idle.
- Unix and Linux. Run the work inside tmux on the host, then attach again after you reconnect. See Keep your work after a disconnect with tmux, and attach automatically.
Related
- Why a session disconnects when it sits idle
- EZZ6034I CONN DROP after idle, TN3270 TIMEMARK and SCANINTERVAL
- Reconnect to a TSO session after the connection drops
- Why an IBM i session ends or signs off when it sits idle
- SSH keep-alives and idle timeouts
- SSH error messages, what each one means
- Connection abort, reset and timed-out errors in SSH and Telnet clients
- Mosh or SSH?
- Keep your work after a disconnect with tmux, and attach automatically
- Cannot connect
- Kill a frozen SSH session with Enter ~. (OpenSSH escape sequences)
- z/VM HCPLGA054E "Already logged on": reconnect with LOGON ... HERE
Sources
- SCANINTERVAL and TIMEMARK, z/OS 3.1 documentation
- The INACTIVE family of timers, z/OS 3.1 documentation
- Using the TSO LOGON command with the RECONNECT operand (IBM z/OS 3.1)
- Disconnected TSO/VTAM sessions ignore the SMF job wait timer (IBM Support)
- Time-out interval for inactive jobs (QINACTITV), IBM i 7.6 documentation
- ssh_config(5): ServerAliveInterval, ServerAliveCountMax and sshd_config(5): ClientAliveInterval, ClientAliveCountMax
- Mosh: how it works and FAQ
- IBM support: Why would a TN3270 session fail with error code 6002 when SSL is enabled?