blinksh / blink

Blink Mobile Shell for iOS (Mosh based)
https://blink.sh
GNU General Public License v3.0
6.18k stars 576 forks source link

Mosh connection to Raspberry Pi doesn’t survive iPad lock/unlock #1048

Closed charliesneath closed 4 years ago

charliesneath commented 4 years ago

I’m a new Blink Shell user, and have been primarily using it to connect to my Raspberry Pi devices (Zero W and 3B+). Between sessions I’ll lock my iPad, and when I open Blink again (even a few minutes later), I get the warning banner that Mosh has lost contact. Sometimes it will recover, but this is inconsistent and unreliable.

Is this expected? I’m assuming that my connection is stable since I’m on my home wi-fi, but maybe my network/router is having an effect?

Please let me know if I can provide more information to debug. I’m very new to this workflow but am excited about the possibilities!

javierdemartin commented 4 years ago

Does this happen only when using mosh or this is for SSH connections? If what you are using is SSH this can be considered normal behavior as it's not able to remember the state so when you open the app later on it doesn't know where you left it.

If you are using SSH this might be due to the session timing out due to an idle connection. Maybe also try to use screen or tmux for long-running commands?

Any details that you can provide are useful to pinpoint where the issue is. Are you running the iOS 14 beta?

charliesneath commented 4 years ago

This is happening when using Mosh specifically, not with SSH. The connection just survived the night but I lost it after moving iPad between rooms this morning. I’m on the newest iPad hardware (12.9”), but not using any beta versions of iPadOS. I’m using the iPad with the Magic Keyboard, which means the device goes to sleep when I close the screen against the keyboard.

I do wonder if it has something to do with my network setup. I’m using a few Google mesh devices in addition to the basic Xfinity modem/router. This means I have 2 wi-fi networks in the house, but only use the one provided by the mesh devices (the basic Xfinity boxes don’t play nicely with the Raspberry Pi’s). The IP addresses of the devices haven’t been changing but maybe the interplay of the two modems creates an issue?

Also, please let me know if there’s any network debugging output I can provide to help identify what’s happening. Thank you for the help!

charliesneath commented 4 years ago

In this screenshot, I’ve highlighted the detached Mosh session. You can see the current one since I have htop open.

Let me know if you need clarification on anything in this list.

IMG_0018

charliesneath commented 4 years ago

It seems that “closing” the iPad against the keyboard is what is killing the Mosh connection.

Is it possible that the iPad enters a different sleep mode when closed against the keyboard?

Again, please let me know what additional information would be helpful to debug!

javierdemartin commented 4 years ago

I haven't forgotten about this :) It's a bit tricky to reproduce the exact same issue and to know if it's a keyboard issue. I'll work on it and let you know once I find something. Thanks for reporting it though.

charliesneath commented 4 years ago

Thank you! I will continue trying to reproduce as well. I am switching to using MacBook for a bit and will report back with whether not I experience similar issues as with the iPad. I won't be using Blink but will still be using Mosh with the RPi devices.

KlasO commented 4 years ago

Hi,

I have experienced a similar problem on an iPad Pro with Magic Keyboard connecting to a Raspberry Pi 4 using Mosh. The problem appears to be intermittent, and I haven't been able to figure out how to reproduce it every time (thank goodness).

I have a Swedish Magic keyboard if that changes anything (and mentioning this here even if I should probably open a separate issue: sometimes the mosh CTRL-^ freezes the session and does not accept any more input. I can open a second session but that's it.)

Kind regards, Klas

javierdemartin commented 4 years ago

Thank you both for your input, I'll get back at you once I have something 👍

javierdemartin commented 4 years ago

I've tested Mosh connections on the following devices for the following devices:

I am running the latest production version of Blink Shell.

So far I haven't had any issues at home. Mosh connections seem stable even after turning the iPad on/off from the hardware button and also closing it against the lid of the iPad Magic's keyboard. They stay up after hours some hours and don't seem to be killed by the keyboard's behavior you explained.

Also, I am using the same Google Mesh routers @charliesneath mentions. Even also moving my iPad around the house in between the routers.

Here are the two connections to the RPi3 and RPi Zero W echoing the hours I opened Blink Shell and what actions I've done.

IMG_0117

Are there any other things you want to be tested?

I don't yet know if the iPad enters a completely different sleep mode when closing it against the keyboard, I'll investigate that in the following days.

charliesneath commented 4 years ago

Thanks, @javierdemartin. I haven’t had any issues connecting with my laptop so far. Will be back to using iPad / Blink as soon as I get my replacement device and will report back then.

javierdemartin commented 4 years ago

No problem, I'll keep an eye if it happens to me though. Keep me posted if you're able to reproduce it!

KlasO commented 4 years ago

Thanks for the effort you put in to test this. I have been busy with other obligations so I have nothing to report.

KlasO commented 4 years ago

Tried connecting to the pi using mosh and left it at the command prompt for an hour, and closed it to the keyboard, after which the turquoise status bar appeared again and the session was dead. Please advise if I can provide more information.

charliesneath commented 4 years ago

Note: there are a few keyboards available for iPad, but this is the one I'm using:

https://www.apple.com/shop/product/MXQT2LL/A/magic-keyboard-for-ipad-pro-11%E2%80%91inch-2nd-generation-us-english

javierdemartin commented 4 years ago

@KlasO I'll give it ago through this week again. @charliesneath yup, I've been testing it with the same keyboard.

If any of you or anyone that comes up through this thread it'd be a great thing to be able to have reproducible steps so we're able to debug this.

levlevin commented 4 years ago

Hi everyone,

Same issue here. v13.5.2.238, iPadOS 14 beta 1, same keyboard (but for the larger ipad). Mosh is losing connection after several minutes with the keyboard closed. I am connecting to the remote cloud machine, but the results are exactly the same

carloscabanero commented 4 years ago

Thanks everyone for keeping an eye on this. I have good news and bad news.

The good news is that we have been able to figure out what is provoking it, and we have a possible workaround while we work on a fix. The problem is the app gets called again after suspension when closed with the keyboard and being in the foreground. This invalidates our previous state - which is protected - and triggers this situation. The workaround is actually really simple, send Blink to the background first and never close it with the keyboard.

Bad news is that you will have to wait a little bit more until we can come up with a proper fix, so apologies for the inconvenience.

levlevin commented 4 years ago

Well, any solution is better than no solution! Thanks for keeping us in the loop)

KlasO commented 4 years ago

Thanks for investigating

charliesneath commented 4 years ago

Awesome! Thanks for digging in. When will this be available in the iPadOS client?

carloscabanero commented 4 years ago

It is already out on TestFlight, we are thinking on pushing today.

carloscabanero commented 4 years ago

This is out!

KlasO commented 4 years ago

Thanks a million!