On Windows clients
Increase/work around idle disconnects: set LanmanWorkstation\Parameters\KeepConn to a higher value (e.g., 65535 seconds). Microsoft Learn+1
Ensure the NIC isn’t being powered down: disable “Allow the computer to turn off this device to save power.” Microsoft Learn
Make logon drive mapping reliable: enable “Always wait for the network at computer startup and logon.” This avoids timing issues so the network is up before mappings are processed. Also ensure “Reconnect at sign-in” on the mapping. Microsoft Learn+1
Prefer mapping by FQDN (stable DNS) vs. IP, and keep client time in sync (Kerberos/SMB signing can be sensitive to clock skew). Microsoft Learn
On the Samba/TrueNAS side
Don’t rely on Windows-only autodisconnect; in Samba the analogous control is deadtime (minutes before idle sessions are closed). Keep it 0 (no idle drop) or set conservatively for your environment. (See smb.conf parameter docs.) Samba
Ensure TCP keepalives are reasonable (Samba uses OS keepalives; very aggressive timeouts on intervening firewalls/VPNs can still kill idle sessions). Samba
Leave durable handles enabled (default for SMB2/3) so clients can seamlessly recover file handles after brief blips. This helps after a hiccup, but it’s not the same as preventing disconnects. wiki.samba.org+1
Keep Samba/TrueNAS up to date; newer Samba (4.22+) has directory leases on by default for non-clustered setups and many SMB robustness fixes. wiki.samba.org