Termux-packages: ssh-server (sshd) is too slow during a session

Created on 7 Oct 2016  路  6Comments  路  Source: termux/termux-packages

When I connect from my linux desktop to my android phone running termux/sshd, usually, it takes several seconds for keystrokes to appear. The phone and the computer are on the same LAN, which is fast. I suspect that there is no problem on the client side, because the client works well with other servers.
Is there a way to make it faster? Perhaps increase the priority of the sshd process on android?
A few months back, I used the ssh server package provided by GNURoot debian. That was slow too.

bug report

All 6 comments

What device is this? I have the same thing on my Sony Xperia X. Do you also use a Sony device?

It seems that my device is very slow to respond to any external connection. It's not just SSH it's also ping and everything else.

ping 172.18.100.171

Pinging 172.18.100.171 with 32 bytes of data:
Reply from 172.18.100.156: Destination host unreachable.
Reply from 172.18.100.171: bytes=32 time=964ms TTL=64
Reply from 172.18.100.171: bytes=32 time=4ms TTL=64
Reply from 172.18.100.171: bytes=32 time=2030ms TTL=64

My guess is that the WiFi goes into a power saving mode when not actively downloading data.

Workarounds that work for me:

Connecting to SSH via USB

This will bypass the WiFi completely. Here's a tutorial

Preventing the WiFi from sleeping

Constantly downlading a little bit by opening a connection to another SSH Server and receiving a constant stream:
ssh someserver -t -- "while true;do sleep 0.1; date;done"; This will prevent the WiFi from going to sleep.

ping 172.18.100.171

Pinging 172.18.100.171 with 32 bytes of data:
Reply from 172.18.100.171: bytes=32 time=2ms TTL=64
Reply from 172.18.100.171: bytes=32 time=3ms TTL=64
Reply from 172.18.100.171: bytes=32 time=3ms TTL=64
Reply from 172.18.100.171: bytes=32 time=3ms TTL=64

Thanks for the detailed answer. I have a samsung galaxy note 4 (N910C) running Android 6.0.1.
Your diagnosis is correct. My phone also takes ages to respond to pings.

PING note4-new.lan (192.168.1.146) 56(84) bytes of data.
64 bytes from note4-new.lan (192.168.1.146): icmp_seq=1 ttl=64 time=6062 ms
64 bytes from note4-new.lan (192.168.1.146): icmp_seq=7 ttl=64 time=64.0 ms
64 bytes from note4-new.lan (192.168.1.146): icmp_seq=8 ttl=64 time=5617 ms
64 bytes from note4-new.lan (192.168.1.146): icmp_seq=9 ttl=64 time=4608 ms
64 bytes from note4-new.lan (192.168.1.146): icmp_seq=10 ttl=64 time=3600 ms
64 bytes from note4-new.lan (192.168.1.146): icmp_seq=11 ttl=64 time=2592 ms
64 bytes from note4-new.lan (192.168.1.146): icmp_seq=12 ttl=64 time=1584 ms
64 bytes from note4-new.lan (192.168.1.146): icmp_seq=13 ttl=64 time=576 ms

As you suggested, I tried connecting over USB, and that was fairly fast. Because the problem is in Android's power saving/wifi, and not in termux, feel free to close the issue.

operating the smartphone as hotspot aka WLAN-AP (if feasible at all) solves all WLAN lag problems for me.

For me, lag occurs only when the screen is off. To solve this, just acquire wakelock from the notification.

solved by setting gEnableBmps=0 in /system/etc/wifi/etc/wifi/WCNSS_qcom_cfg.ini on a rooted nexus4

@Neo-Oli Thanks for your simple workaround!

It fits my case perfectly, because I _do_ want wifi to sleep if I'm not using SSH.

Here's what I do: ping the (local) DNS server with an interval of 0.5 seconds, which seems to suffice.

ssh mobile 'ping -i 0.5 $(getprop net.dns1) >/dev/null'  # prevent wifi from sleeping
ssh mobile
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  70Comments

NLKNguyen picture NLKNguyen  路  59Comments

angrykoala picture angrykoala  路  83Comments

urrut picture urrut  路  51Comments

skittles9823 picture skittles9823  路  65Comments