3

I upgraded termux recently.

When I do:

ssh phone

it disconnects after 44 seconds. It disconnects even if there is activity in the session (eg. ping google.com).

If I am active in termux using the phone, then ssh does not disconnect. So it seems Android is killing the ssh connection. tcpdump confirms that and shows a reset packet is sent from the phone killing the connection:

13:30:37.093254 IP 192.168.1.122.2222 > 192.168.1.129.41938: Flags [R.], seq 4542, ack 5622, win 396, options [nop,nop,TS val 3374991 ecr 3768615485], length 0

Before upgrading termux this did not happen. So something happened during the upgrade that caused this to happen.

I have tried both to click acquire wakelock and release wakelock. Neither helped.

I have tried both to click allow and don't allow in Battery Optimization for Termux. Neither helped.

As a workaround I can connect USB. Then Android does not disconnect the ssh-connection. This makes me think the disconnection is deliberate and related to power saving.

How can I make Android not kill the ssh connection?

Ole Tange
  • 386
  • 1
  • 4
  • 17
  • Android isn't killing ssh but Termux app because it doesn't have a background service running. You need to keep Termux in foreground. Or disable Battery Optimization for Termux and Acquire wakelock. When phone is charging over USB, Battery Optimization isn't in effect. – Irfan Latif Nov 03 '19 at 14:55

1 Answers1

2

Thanks to @IrfanLatif I looked at battery options again.

And my phone was in Power Saving mode. When I disabled that, everything worked - whether Termux is running in the foreground or not.

So the problem was not related to the upgrade of Termux.

Ole Tange
  • 386
  • 1
  • 4
  • 17