LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Support for Android version of Total Commander

Moderators: Hacker, petermad, Stefan2, white

nabijaczleweli
Junior Member
Junior Member
Posts: 2
Joined: 2017-07-12, 17:47 UTC
Location: Kraków, Poland

LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *nabijaczleweli »

On LineageOS 14 (Android 9) with Total Commander 3.0b12 and TotalCmd-LAN (Windows shares) 3.09, when connection is lost to a share (phone off, wifi off, whatever), opening a folder either (a) succeeds transparently, (b) fails once with "connection lost" or "j has already been closed", then you see the same folder view, and clicking it opens the folder, or (c) fails once with "j has already been closed", you get booted to home screen, and you can open the share again and it connects.

On LineageOS 21 (Android 14) with Total Commander 3.50d and TotalCmd-LAN (Windows shares) 3.50 (as well as another similar Android 12 (Sony stock) installation), you always get "j has already been closed", booted to home screen, and opening the share again gives "j has already been closed" ad mortam defecatam. The only way to solve this is to kill Total Commander by swiping it away from the task switcher but this doesn't really work if you're playing audio through the TC media queue (notification keeps it alive so you need to kill the audio, kill TC, reopen the queue, maybe requeue and seek).

This feels like it should Just™ reconnect transparently, as it (by accident?) did under 3.0b12/3.09.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *ghisler(Author) »

1. Can you tell me which version of Samba your server is running? So far I haven't been able to get the error "j has already been closed".
You can use one of the following commands:
smbstatus --version
or
smbd -V
2. When exactly does this happen? Do I need to keep the connection open for a longer amount of time?
Author of Total Commander
https://www.ghisler.com
www.manyplay.de
New Member
New Member
Posts: 1
Joined: 2024-05-05, 18:35 UTC
Location: earth
Contact:

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *www.manyplay.de »

hi,
this problem exists also on network drives (ds-play,d-link - etc pipi), when they are in hibernate mode.

clicking on a content for example a media file, does not refresh the device and its still "sleeping".

only after a hard termination of the lan plugin in apps (i tried it with several from A5 to 14) gives
you a chance to open the connection again.

after a reconnect the network device starts spinning again and a connection apears till the next
hibernation/spindown starts again.

the easiest way is to integrate a "stop plugin" wenn TC checks that a connection is already given.

the message "...is already closed" happens after clicking again on that connection to obtain a new one
after already one was taken for this connection a while ago.

the device does not respond and the message apears...
Bzdoorek
Junior Member
Junior Member
Posts: 8
Joined: 2024-07-24, 16:39 UTC

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *Bzdoorek »

Same problem. Samsung Galaxy 22, Android 14, samba Version 4.9.5-Debian.

Connecting to the server, copying files, leaving the phone just lying for some time (no idea how long, say several hours), trying to copy some other files - "j is already closed". Can't find a way to reconnect unless I just swipe the TC away from the app list. Then it nicely asks for my fingerprint to log in and works - till the next time.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *ghisler(Author) »

Which server? Maybe it's some exotic server which closes the connection without being told to do that.

Or maybe some kind of power saving function on your phone is closing the connections?
Author of Total Commander
https://www.ghisler.com
Bzdoorek
Junior Member
Junior Member
Posts: 8
Joined: 2024-07-24, 16:39 UTC

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *Bzdoorek »

This is just a slightly outdated Debian machine running 24/7, Linux 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64, mostly used as NAS, nothing fancy. Could be Android goes to sleep and disconnects, but I am OK with that. Problem is not that it disconnects, problem is when it does and displays the "j is already closed" message there is no way to connect back without swiping app away.

Right now for the first time it worked OK - it asked for a password/fingerprint and reconnected as it should after unlocking the phone. I can't think of what I could do differently than on previous occasions. I connected and copied some files yesterday, since then never touched the TC app, but used the phone as usual, both at home and away.
JOUBE
Power Member
Power Member
Posts: 1664
Joined: 2004-07-08, 08:58 UTC

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *JOUBE »

- I have little understanding for leaving a connection open for hours, especially on a mobile device. That is uncommon and unusual. What is the reason? Did you simply forget to close it?

- If you use a mobile device and move around in other networks while the connection is supposedly open, then return to the original network and expect the connection to continue and you only have to press reconnect: How is that supposed to work?

- The fact that it worked now (see you last post) may be because this time there was no network change in between.
Bzdoorek
Junior Member
Junior Member
Posts: 8
Joined: 2024-07-24, 16:39 UTC

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *Bzdoorek »

I expect it to work similarly to every other program on mobile - I don't close it, it is just moved to background. It is not that I am "leaving a connection", I just expect the program (as virtually every program in Android environment) to manage resources and save its state in a reasonable way on its own. If it will drop the connection when going into background and it will attempt to reconnect when brought back, asking for credentials - that's OK.

What is not OK is that there is a bug that stops it from reconnecting.

Could be it is in some way related to the LAN network changes, but I doubt - I am 99% sure network at home is the only WiFi my mobile connects to. I live in a rural area and I strongly doubt there are any public LANs available. It can disconnect, it can even try other networks, but it has no credentials to log into them.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *ghisler(Author) »

Could you enabled logging in Total Commander?
Main menu (3 dots) - Configure - Create a log file (near the bottom)?
Then when it happens again, post the last few lines from the file here. You may replace sensitive data like host names with a modified text.
Author of Total Commander
https://www.ghisler.com
Bzdoorek
Junior Member
Junior Member
Posts: 8
Joined: 2024-07-24, 16:39 UTC

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *Bzdoorek »

Sorry, forgot to switch mobile to English, so some reports are in Polish. Not that they add a lot - "Skopiowano" means "copied", "Błąd podczas łączenia z serwerem! Raport błędu:" means "Error connecting to server! Error report:" or something like that.
2024-07-29 14:19:52.238 HOST:LAN:initiate connection to plugin
2024-07-29 14:19:52.245 HOST:LAN:bindService succeeded
2024-07-29 14:19:52.256 HOST:LAN:WaitUntilConnected:Background
2024-07-29 14:19:52.321 HOST:LAN:Service connected!
2024-07-29 14:19:52.326 HOST:LAN:get dir: /
2024-07-29 14:19:52.351 HOST:LAN:checkConnectionAlive: 1
2024-07-29 14:19:53.988 HOST:LAN:get dir: /HomeNAS/
2024-07-29 14:19:54.016 LAN:CONNECT HomeNAS
2024-07-29 14:20:01.361 HOST:LAN:get dir: /HomeNAS/HomeNAS/
2024-07-29 14:20:03.089 HOST:LAN:get dir: /HomeNAS/HomeNAS/Bzdoorek/
2024-07-29 14:20:12.157 HOST:LAN:get dir: /HomeNAS/HomeNAS/Bzdoorek/
2024-07-29 14:20:12.259 tc:Copy 1 files:/storage/emulated/0/DCIM/Camera/->///LAN/HomeNAS/HomeNAS/Bzdoorek/
2024-07-29 14:20:13.097 LAN:Skopiowano: content://com.ghisler.files/storage/emulated/0/DCIM/Camera/20240728_231351.jpg -> /HomeNAS/Bzdoorek/20240728_231351.jpg, 4229763 bytes, 5131.2 kbytes/s
2024-07-29 14:20:13.290 HOST:LAN:get dir: /HomeNAS/HomeNAS/Bzdoorek/
2024-07-29 15:01:49.087 HOST:LAN:checkConnectionAlive: 1
2024-07-29 15:01:49.091 HOST:LAN:get dir: /HomeNAS/HomeNAS/
2024-07-29 15:01:49.113 LAN:Błąd podczas łączenia z serwerem! Raport błędu:
j has already been closed
/HomeNAS/
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *ghisler(Author) »

It looks like you left the connection open after uploading a file, and then the server kicked you out after a while. But the smb library assumed that you were still connected.

Could you try clicking on the plugin icon in the lower toolbar and choose "Disconnect" after uploading the file? This should close the connection gracefully, so you don't get kicked out.

I'm still trying to figure out why the plugin can't handle it - I have code in there which reacts to "has already been closed" by discarding the open connections, but it doesn't seem to work on your device.
Author of Total Commander
https://www.ghisler.com
Bzdoorek
Junior Member
Junior Member
Posts: 8
Joined: 2024-07-24, 16:39 UTC

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *Bzdoorek »

This is strange - if I click the plugin icon right after copying the file it displays "Plugin LAN: Disconnected" message, despite being connected (I can still copy files and browse the server).
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50386
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *ghisler(Author) »

No, it shows a popup menu titled "Plugin: LAN" with one menu item below it, "Disconnect". You need to click on this menu item to close the connection.

This will return you to the list of connections.
Author of Total Commander
https://www.ghisler.com
Bzdoorek
Junior Member
Junior Member
Posts: 8
Joined: 2024-07-24, 16:39 UTC

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *Bzdoorek »

Ah, OK, Polish translation is misleading - it doesn't say "Disconnect", it says "Disconnected".

Makes sense, will try later.
User avatar
Rajesh
Junior Member
Junior Member
Posts: 5
Joined: 2024-05-18, 15:46 UTC

Re: LAN plugin no longer reconnects after failing with "j is already closed", requires force kill after connection loss

Post by *Rajesh »

Bzdoorek wrote: 2024-07-30, 12:07 UTC Ah, OK, Polish translation is misleading - it doesn't say "Disconnect", it says "Disconnected".

...
Hello,
if you use this and are sure, then you can change the expression in the translation.

Link : https://www.ghisler.ch/board/viewtopic.php?t=81004#p449729
Post Reply