3

Scenario1: I SSH from my employer (OSX Yosemite SSH client) to my home server (Debian stable) and (re)connect to a tmux session. If I leave the terminal inactive for a while (~20minutes), it seems like the network connection has been interrupted for too long with the famous SSH error: "broken pipe". If I log back in the tmux behaves as expected: the session is still alive.

Scenario2: I SSH from my employer to my home box. Now I do the stuff I usually do but this time not in a tmux session. Now I can leave the terminal inactive for hours and hours, it does not die.

Scenario 3: I SSH from my own home network segment to the same server and connect to a tmux session. Now I get the expected behaviour. The terminal does not lose the connection after a period of inactivity, with our without using tmux.

I have tried to Google my question but the problem is that I get answers to the wrong question: Q: I use SSH for a long running command, how can I reconnect if I get a broken pipe? A: Have you heard of tmux? Yes I have ... . But I haven't heard of broken pipes being caused by tmux.

I also asked the question on irc but I didn't get a reply there.

1
  • I have the same problem. MacBook Air, broken pipe on sleep with tmux, no broken pipe without tmux. ServerAliveInterval & KeepAlive were already set BTW. Apr 24, 2021 at 15:06

2 Answers 2

2

Enable SSH keepalives globally in /etc/ssh_config or in your home directory ~/.ssh/config

KeepAlive yes
ServerAliveInterval 60

Before I found this openssh option, I would run "top -d 60" to keep the connection alive.

4
  • 1
    I have tried both of your suggestions but I still get the broken pipes after some time.
    – buco
    Feb 2, 2015 at 9:23
  • There are always things outside of your control, like a router/NAT box dropping connections. Are you using a router on your network? Are there any settings you could tweak, for example to increase connection time-outs? Feb 3, 2015 at 0:43
  • You're correct, I've been thinking that too.On the other hand, I create an SSH tunnel from work till home. How can router settings/NAT have an effect on SSH connections staying alive when I do nothing at all and SSH connections being lost when I run tmux inside it?
    – buco
    Feb 3, 2015 at 14:53
  • I have the same problem on the same switch. KeepAlive & ServerAliveInterval were already set. This is some peculiar interaction between OS X terminals, sleep, & tmux. Apr 24, 2021 at 15:09
0

I'm half guessing this has to do with 'keeping the session alive', aka 'pings'. There's config options for that kind of thing. Tmux doesn't mind being disconnected, and -ideally- you shouldn't leave unused connections open; that's bad network etiquette ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .