Fixing Blink (blink.sh) mosh disconnects when accessing macOS
After a couple of years I have recently restarting using my Apple iPad Pro 12.9” as my main computing access device. I have used this setup before in 2017, for a couple of years, when I moved away from laptops and desktops to this more simplistic setup. Of course, these days there are lots of people trying out the iPad only approach.
As one of my hobbies is programming, I still need to have access to a computer that provides such an environment for development. Luckily, this is simplistic too - a command line shell and an editor, and of course the language support for whatever I am currently developing programs in. Back in 2017/2018 this extra computer functionality was provided by a Raspberry Pi, with a great program called Blink running on the iPad to access it.
It is now 2023, and I had evolved my computer use to Apple M1 laptops and M1 mac Mini. I still have the Raspberry Pi, but due to time constraints, I just admin the Apple devices day to day, and the Raspberry Pi is turned off unless needed.
How Does Blink Get Used?
Blink is running on the iPad and can connect to a remote computer using either ssh or via mosh. Blink includes support for both. The ssh protocol is still used with mosh, but mosh adds a seamless wrapper around a ssh connection to improve dramatically any connection issues. This ensures the Blink connection to the remote computer is maintained, even when the application is not being used, or the network connectivity drops out.
To double protect the Blink session, I also run my shells on the remote computer in Zellij as well - which is a great replacement for screen that I used to use. This ensures the programs I am running on the remote computer are maintained and can be re-accessed, should Blink completely disconnect.
On the remote computer, Zellij and mosh need to be installed. If the remote
computer is running macOS or Linux, then the package manager should already
have them available. On macOS, they are both available via Homebrew
using the command:
brew install zellij mosh
The Issue with Blink and mosh
When using Blink with macOS Ventura running on a MacBook Pro M1 the mosh shell would disconnect after a minute or so.
The time between successfully connecting with the Blink builtin mosh client, to the MacBook Pro M1 mosh server, and then it dropping would be roughly a minute. The same would not happen when connecting via ssh directly instead of mosh. This led me to believe it was a timeout somewhere that was causing the automatic disconnect from the remote computer.
The cause turned out to be a setting found here in the laptop macOS settings:
System Settings -> Displays -> Advanced button -> option Prevent automatic sleeping on power adaptor when the display is off : enable
Once this was enabled (ie as shown above) the connection made via mosh to the laptop were very reliable again.
Of course it all makes sense once you have located the cause, but finding that particular setting on the MacBook Pro took a few minutes. The fact a global sleep setting for the computer was buried under the display preferences is also odd in my view.
- Title: Fixing blink.sh and mosh on macOS
- Published Date : 26 Feb 2023