smallperson / connectbot

Automatically exported from code.google.com/p/connectbot
Apache License 2.0
0 stars 0 forks source link

Local shell gets disconnected when connectivity is lost (fix suggested inside) #417

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Start a Local shell in connectbot
2.Switch the device to "airplane mode"
3.Local shell gets closed although it does not involve the network.

What is the expected output? What do you see instead?

Local shell should remain connected regardless of connectivity state.

What version of the product are you using (you can see this by using Menu
-> About in the Host List)?
1.7.1

What type of system are you trying to connect to?

local

If you are able to connect, what is the output of "echo $TERM", "uname -a",
and any other relevant information on the host?

not relevant.

Please provide any additional information below.

Here's what happens:

D/ConnectBot.ConnectivityManager( 2248): onReceived() called; noConnectivity? 
true; isFailover? false

at this point, onReceive sets mIsConnected=false and calls 
mTerminalManager.onConnectivityLost() which calls disconnectAll(false) rather 
than disconnecting only network connections.

This follows with an error from Relay because it has been disconnected:
E/ConnectBot.Relay( 2248): Problem while handling incoming data in relay thread
E/ConnectBot.Relay( 2248): java.io.IOException: session closed
E/ConnectBot.Relay( 2248):      at 
org.connectbot.transport.Local.read(Local.java:149)
E/ConnectBot.Relay( 2248):      at 
org.connectbot.service.Relay.run(Relay.java:129)

Solution:

Replace disconnectAll() with a new disconnectRemote() that only dispatches 
Disconnect to bridges that have transport != Local.

Original issue reported on code.google.com by weiss.y...@gmail.com on 20 Jan 2011 at 9:34

GoogleCodeExporter commented 9 years ago
Confirm this issue here, using CM 7.0 RC2.  This is a particularly annoying 
problem, in that if one's wifi is just in range, it will constant disconnect 
localhost as a result... 

Original comment by btwilli...@gmail.com on 13 Mar 2011 at 3:53

GoogleCodeExporter commented 9 years ago
I implemented a hack that essentially does what is suggested in the problem 
description, if you don't want to wait until this is properly fixed you can 
just apply the patch and build connectbot yourself. 

Original comment by sido...@gmail.com on 6 Apr 2011 at 11:43

Attachments:

GoogleCodeExporter commented 9 years ago
I verified that the patch works.  Thanks for the clean and useful patch.  I 
hope it's incorporated in the next release.

Original comment by weiss.y...@gmail.com on 10 Apr 2011 at 3:16

GoogleCodeExporter commented 9 years ago
Thanks for the patch!

Hopefully future releases of connectbot will address this, so that any 
connection dropping, will not effect another connection.

That is, if my wifi drops, but I'm using 3G for connectbot, nothing should 
change.  Same for the reverse.  Many people do not use insecure ssh keys 
without passwords, so auto-relogin is not possible....

Original comment by btwilli...@gmail.com on 20 Apr 2011 at 2:14

GoogleCodeExporter commented 9 years ago
I was unable to get this to work; the test 
"!tmpBridges[i].transport.getProtocolName().equals("local")" always failed, I 
dumped the value to logcat and it showed up as 'unknown'. Not being able to 
resolve this, I simply opted to do this:

@@ -660,7 +669,7 @@ public class TerminalManager extends Service implements 
BridgeDisconnectedListen
                final Thread t = new Thread() {
                        @Override
                        public void run() {
-                               disconnectAll(false);
+                               //disconnectAll(false);
                        }
                };
                t.setName("Disconnector");

That works for me.

Original comment by infer...@gmail.com on 28 Jun 2011 at 1:45

GoogleCodeExporter commented 9 years ago
changed this in localdisconnect.diff

-if (!onlyRemote || !tmpBridges[i].transport.getProtocolName().equals("local"))
+if (!onlyRemote || 
!tmpBridges[i].transport.getProtocolName().equals("local")|| 
!tmpBridges[i].transport.getProtocolName().equals("unknown"))

That works for me.
Only disconnect remote hosts.

Original comment by giuliolu...@gmail.com on 8 Sep 2011 at 2:01

Attachments:

GoogleCodeExporter commented 9 years ago
When will this fix be applied to the official build?

Original comment by tomlo...@gmail.com on 5 Oct 2011 at 3:28

GoogleCodeExporter commented 9 years ago
This is the patch I used.

http://code.google.com/r/chunlinyao-connectbot/source/list?name=nolost

Original comment by chunlinyao@gmail.com on 29 Jan 2012 at 8:35

Attachments:

GoogleCodeExporter commented 9 years ago
Any chance this will ever get looked at?  It's a ridiculous bug, and as I do a 
lot of local terminal work on my phone while moving about, it's a big 
annoyance.  I have to remember to always work in GNU screen.

It seems like the fix is simple enough, no?  And I don't get why this 
auto-disconnecting behaviour would be desired even for remote connections.

Original comment by alexb...@gmail.com on 25 Apr 2012 at 8:08

GoogleCodeExporter commented 9 years ago
would you like to send me a fixed and built .apk?
Thanks!

my email address is zhangew@gmail.com

Original comment by zhan...@gmail.com on 9 Mar 2013 at 3:29

GoogleCodeExporter commented 9 years ago
#5's method worked. Thanks!

I built a new apk myself. Thanks!

Original comment by zhan...@gmail.com on 9 Mar 2013 at 4:03

GoogleCodeExporter commented 9 years ago
Unfortunately this has not been patched yet and is still a problem. I ended up 
setting up a development environment last night and compiled the patch from #6. 
The diff files are out of date though so I had to do it manually. Here is a 
link to a compiled version of the fix:

https://dl.dropboxusercontent.com/u/4357139/connectbot_signed_test.apk

Original comment by hat...@gmail.com on 18 Sep 2013 at 6:19

Attachments:

GoogleCodeExporter commented 9 years ago
So, three years with patch submitted, confirmed and working and this is still 
not fixed? That's not funny anymore...

Original comment by sk.ko...@gmail.com on 26 Jan 2014 at 12:56

GoogleCodeExporter commented 9 years ago
https://github.com/vx/connectbot/issues/20 says:
Don't monitor network state in local mode (#20) …
Based on upstream's issue #417 patch. Fixed to use instanceof instead of
getProtocolName(): this method is static and will always return
"unknown".

I'm guess I'll be looking into VX Connectbot. I went looking when I got the 
e-mail update from this ticket, and they seem to have fixed this and a slew of 
other issues still open in this tracker. The app seems to have pretty good 
reviews. so, open source in this case is both a curse (3 years and no patch 
integration?) and a blessing (fine, we'll just go use that updated fork over 
there!) as usual :)

https://f-droid.org/repository/browse/?fdid=sk.vx.connectbot

Original comment by overpres...@gmail.com on 26 Jan 2014 at 11:27