Slow file list using jCIFS on Windows

jCIFS is a great library for connecting to SMB shares on Android, and it works great with almost all the settings I tested.

However, I take advantage of incredibly low performance when using the method SmbFile.listFiles()for Windows network shares, but only when logging in as an actual user on a PC. It may take up to several minutes to simply get a list of folders, and sometimes nothing happens at all.

If I decided to log in as a guest (using the "guest" as a user and leaving the password blank), everything is fast. Usually less than a second.

The following code works fast:

try {
   NtlmPasswordAuthentication authentication = new NtlmPasswordAuthentication("", "guest", ""); // domain, user, password
   currentFolder = new SmbFile("smb://host-name-for-my-pc", authentication);
   SmbFile[] listFiles = currentFolder.listFiles();
} catch (Exception e) { // Using Exception for the sake of demonstration...

This code, however, does not work / very slow:

try {
   NtlmPasswordAuthentication authentication = new NtlmPasswordAuthentication("", "my-username", "my-password"); // domain, user, password
   currentFolder = new SmbFile("smb://host-name-for-my-pc", authentication);
   SmbFile[] listFiles = currentFolder.listFiles();
} catch (Exception e) { // Using Exception for the sake of demonstration...

, jCIFS, .

ES File Explorer, jCIFS, , .

Update:

SmbFile("username:password@server/") , ! , NtlmPasswordAuthentication. ?

+5
3

new SmbFile("username:password@server/") , .

+5

jCIFS:

jcifs.Config.setProperty("resolveOrder", "DNS");

JCIFS: ,

Ref: https://jcifs.samba.org/src/docs/api/overview-summary.html

+2

Try to use new SmbFile("smb://host-name-for-my-pc/", authentication);. With a slash at the end.

+1
source

All Articles