GNOME Bugzilla – Bug 578139
smb mounts stop working after idle time
Last modified: 2015-03-27 20:20:03 UTC
the bug has been described on https://bugs.launchpad.net/bugs/310932 "I have a two Samba Servers, one on Suse 11 and one on FreeBSD and Ubuntu Desktop shows the same problems. I have some Network Resources bookmarked. When I need to access a certain place, I simply use the bookmark, which works fine and a Shotcut is created on the desktop, which also works great. After idleing around, I like to access the network share again but the shortcut on the Desktop errors out, so does the bookmark - the errors are attached. I have to unmount the resource and access it then via the bookmark (abviously as the desktop shortcut gets removed) and can happily access the network resource. Desired effect: - I like to access my Samba Server independently of how much time passed meanwhile http://launchpadlibrarian.net/20688781/Screenshot--%20on%20trinity.dominion.ch%20%28smb%3A--trinity.dominion.ch-data%29%20-%20gedit.png" http://launchpadlibrarian.net/20688782/Screenshot-Untitled%20Window.png
I experience the same bug. I noticed the frequency off disconnects varies per windows share. Perhaps the problem arises when the server is reaching it's max connections.
AFAIK, libsmbclient (what gvfs uses for smb) should reconnect if the connection times out. However, in my testing, this doesn't work properly. I have opened an upstream bug for this: https://bugzilla.samba.org/show_bug.cgi?id=10615
On this bug report https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/1401917, Samuel Seay says that gvfs (or libsmbclient, I don't know which one should do that) should periodicaly sends a SMB Echo Request packet to keep the connection up. This would make sense, because a periodic "ls" on the share is sufficient to keep the mount alive.
It's possible to set the idle timeout to be really low (like 10 seconds) which would break hacks like this. E.g. how often is periodic? In my testing, libsmbclient reconnects automatically after an idle drop which is how it should work, but it only does it properly after it has failed once... If you want this to progress, hassle the Samba people :-) (see the bug I filed in comment 2)
I reported this bug on Launchpad (bug #1401917). The issue is that gvfs is not sending the periodic smb echo request command while other smb utilities like cifs does send the echo request to avoid the timeout. If gvfs was modified to send the smb echo request it would fix the timeout issue. This was tested by running wireshark and watching all smb traffic. The server eventually disconnects gvfs due to a server side idle timeout but gvfs ignores that the socket is closed and attempts to continue using it.
gvfs uses libsmbclient which should handle this but doesn't correctly nor does it expose the ability to send echo requests. Hence the bug report in comment 2.
To connect some dots: I think I'm having problems with this same issue. What I see is bad behavior in Deja Dup, which is a backup program that can store backups to Windows shares. It runs automatically at night, and if I happen to have mounted the shared drive where it stores stuff before I leave work, I arrive the next morning and see a "software caused connection abort" error message and the backup has failed. I think what's happening is that the server times out, and the connection doesn't recover gracefully. I found this bug report https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1321354 which suggests running a script to look at the gvfs mounts every 5 minutes. This works -- I think it keeps the server from timing out, and my backups are working without an error as long as the script is running. It greatly improves the responsiveness of Nautilus as well.
This has been fixed upstream and backported to 4.2 and 4.1: https://bugzilla.samba.org/show_bug.cgi?id=11079 If you want this fixed, please ask your distros to backport the relevant patches (or wait for new releases of 4.1 or 4.2).