a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

App tries to restore the previous session after ssh login

Open XarisA opened this issue 6 years ago • 9 comments

Hi and thank you for this great app! It was basically the only thing I missed from Android when switched to iOS. But I’ve come to a small issue. On iPhone killing the app does not reset the session. After a successful ssh login .. exit the session and clear the output when I open the app again it tries to reconnect to the last session as shown below.

image

Something that produces an error because OpenVPN is normally closed. Even when I clear the session .. exit and kill the app it still tries to reconnect. If openvpn is connected it will just relogin to the session as you can see

image

This occurs on iPhone with iOS 13.5 but the issue existed also in 13.4.1. I don’t know before that.

XarisA avatar May 30 '20 03:05 XarisA

Hi, that is a question that is open for discussion, but for me it seems logical that if a command was running when the session was terminated, then when the session is restored, this command is also restored. It makes a lot of sense for vim, for example, and even for ssh in my opinion.

Or do you mean that you were running a ssh connection, then exit the connection, then left the App, and when you come back it tries to re-open the connection?

holzschu avatar May 30 '20 06:05 holzschu

Hi, that is a question that is open for discussion, but for me it seems logical that if a command was running when the session was terminated, then when the session is restored, this command is also restored. It makes a lot of sense for vim, for example, and even for ssh in my opinion.

Or do you mean that you were running a ssh connection, then exit the connection, then left the App, and when you come back it tries to re-open the connection?

Sorry for not being clear. Yes I meant that although I exited the connection and left the app, it tried to reopen it. I also tried to exit the connection , clear ,and then exit the app..(even kill the app) but it continues to try reopening no matter what. And I can’t find a way to reset the session. I also tried to create a newWindow but it keeps trying after reopening, even if I use some other commands after exiting the connection.

XarisA avatar May 30 '20 07:05 XarisA

I cannot reproduce the behaviour on my iPad. I'm going to try on the phone. The fact that it keeps trying even after you ran more commands after exiting the connection is especially puzzling. It should really not do that, we only store the last command.

holzschu avatar May 30 '20 07:05 holzschu

I cannot reproduce on my phone either, but I may have an idea by looking at the code. It boils down to the order in which I save the content of the session. Right now, the current command is saved last, after I've saved the text content of the terminal. There is a possibility that the App is terminated before the "saving the content of the terminal" step returns, which would impact the current command being saved.

I've tried reversing the order (first save the current command, then store the text content of the terminal). We'll see if that changes things.

holzschu avatar May 30 '20 09:05 holzschu

Great thanks! I can test using Testflight when you are ready if you want

XarisA avatar May 30 '20 09:05 XarisA

Build 91, on TestFlight now, has this change. Please let me know if it changes anything.

If it doesn't, the next step is to limit the text content that is being saved. Saving the entire content of the session is slightly too much, but I need to cut at the right point or it will break down some ANSI escape sequences.

holzschu avatar Jun 01 '20 06:06 holzschu

The problem seems to be a little more complex than I thought or it might seemed.

I did the following:

  • I have tested in the new build and the problem still occurred.. plus a doubled cursor issue. cursor
  • Then I uninstalled the app and reinstalled (1.4.3) just to clear everything. I copied the ssh keys, connected and the problem still seemed to occur.
  • Finally I've switched back to 1.4.2 and instead of copying the ssh keys I now connected by using ssh -q plus the password prompt window. I logged out ssh, cleared the output and everything worked like a charm!
  • I assumed that it could be happening when connecting using the ssh keys.. so I regenerated them and tried again but still worked fine!
  • Now I cannot reproduce the error. The only thing that could have changed since before is the content size.

I can close the issue and reopen it if/when I have more info. What do you think?

XarisA avatar Jun 01 '20 12:06 XarisA

Thank you very much for this detailed report. From the look of the prompt $, I think the double cursor issue comes from the terminal using a non-available font (which should not happen). It's a bug in build 91, which will be fixed in build 92.

From what I gather, the issue is related to content size. Since the entire content of the session is saved, each time, and sessions are restored, a session that has been running for a long time can generate content that is just too large to be saved. I should clamp the saved text to a certain length. It's probably a good idea for memory usage, too. The question is "how big is too big", and how to test that. Do you know for how long this particular session has been running?

I would prefer to leave this issue open, so I can keep it in mind and come back to it.

holzschu avatar Jun 01 '20 12:06 holzschu

In the initial sessions that made the issue occur, I performed an upgrade on arch linux server. So the connection time was not more than 10 minutes, but the content that was produced was very large indeed. I can log it the next time and upload a link here so you can have a look. The arch server has more updates than the most linux and the truth is that can produce large content, so it might stretch the save content functionality of the app. I suppose that there are also other tools like pip that could produce large content but I haven't had the issue.

Limiting the saved content size seems a great idea indeed! And as you said it could also help in memory usage!.

XarisA avatar Jun 02 '20 05:06 XarisA