adrift on a cosmic ocean

Writings on various topics (mostly technical) from Oliver Hookins and Angela Collins. We have lived in Berlin since 2009, have two kids, and have far too little time to really justify having a blog.

Mobile shell and high latency connections

Posted by Oliver on the 3rd of February, 2014 in category Tech
Tagged with: latencymoshnetworkshell

I seem to recall first being introduced to MOSH after I saw a link to it in my RSS feed, and almost simultaneously in my work's developer mailing list (where people tend to post about new and interesting technologies). People were literally losing their shit over it (well, ok, not literally) and declaring they would never use anything but MOSH ever again. I may be dramatising somewhat.

It's certainly an interesting piece of software and I could see it might be of utility if you really do work "mobile" a lot of the time or have really shoddy connectivity, but I'm not under any illusion that most of the people I know actually have it that rough. 1st world problems and all of that. In any case, I now actually have a chance to use it since I'm working remotely and with much greater latency to the servers than I'm used to. I realise that up until now I've had it pretty good - most of our servers are easily within 100ms of us (continental Europe) and those that aren't so close are usually on the east coast of the U.S. I have an account on a server back in Sydney, which is almost intolerable to use, but I barely ever use it.

So I installed MOSH and gave it a run. It is undoubtedly good for typing actual letters and deleting them - I will give it that much. There is nothing quite as horrible as making several typos and thundering on with the rest of the line only to realise that you must awkwardly backspace (usually just a few characters at a time to ensure you don't go too far by accident) or move the cursor back to the scene of the crime. Once you get there, it's another laborious process of fixing the error and moving back to where you left off. I won't go into more detail - you understand the problems MOSH is trying to solve.

The underliney thing it does is great, and I truly enjoyed the performance improvement as already stated. Yes, you do have to wait at the end for a moment so that the remote end can confirm it has received your keystrokes, but you generally already know it is fine at that point. The few times my connection or VPN has dropped, MOSH has kept the session around and even printed a little message at the top of the screen to tell me about it. That was pretty awesome.

But the terminal experience could be even tighter. Moving the cursor by itself is for some reason unbuffered (or at least feels that way) - it is just as slow as if I were using normal SSH. I don't see why this has to be the case, as it is not actually changing anything, and could presumably perform the same optimisations on the cursor positioning. Delete (rather than backspace) also (at least as far as I could tell) would drop back to regular unbuffered speeds. Given that I often can't remember more shell shortcuts than Meta-Del, Ctrl-e, Ctrl-a etc I'm often using the cursor keys for navigation so this frequently kills me.

I was also not entirely sure how it would go combined with a screen session, but there didn't seem to be any problems there. Overall I would definitely recommend it, if you have an unreliable or high-latency connection - it is far better than "raw" SSH. But I really hope the developers have further ideas to tweak and tune the experience - it goes perhaps half of the way to being truly awesome but is not quite there yet.

© 2010-2018 Oliver Hookins and Angela Collins