[jcifs] DFS Links and Timeouts

Martin D. Pedersen mdp at visanti.com
Fri Dec 16 14:38:30 GMT 2005


Hi jcifs guys

I'm having some problems with DFS Links.

I have the following DFS setup. 
   //primary/dfs/link   link point to //secondary/data

When I traverse //primary/dfs/link I am transparently redirected to
//secondary/data (in theory).

But jcifs somehow timeouts when accessing files through dfs links. 
If i traverse the files directly from //secondary/data there is no
problem!

Here is my example code:

import jcifs.smb.SmbFile;

public class SmbTimeout {
	
	public static void jcifsScan(String root, String userName,
String password, int sleepTime) throws Exception {
	    System.setProperty("jcifs.smb.client.username",userName);
	    System.setProperty("jcifs.smb.client.password",password);
	    long start = System.currentTimeMillis();
	    SmbFile smbRoot = new SmbFile(root);
	    SmbFile[] files = smbRoot.listFiles();
	    for(SmbFile f : files) {
	    	System.out.println(f.canRead()+" :
"+(System.currentTimeMillis()-start));
		Thread.sleep(sleepTime);
	    }
	    
	}
		
	public static void main(String[] p_args) throws Exception {
		if(p_args.length!=4) {
			System.out.println("Usage: <smbroot> <username>
<password> <sleeptime(ms)>");
			return;
		}
		String smbRoot = p_args[0];
		String userName = p_args[1];
		String password = p_args[2];
		int sleepTime = Integer.parseInt(p_args[3]);
		jcifsScan(smbRoot,userName,password,sleepTime);
	}
		
}

When running:
Java -classpath .:jcifs-1.2.7.jar SmbTimeout smb://primary/dfs/link/
user password 16000
I get: 
true : 744
false : 16760
false : 32777
[...]

But when I run:
Java -classpath .:jcifs-1.2.7.jar SmbTimeout smb://secondary/data/ user
password 16000
I get:
true : 560
true : 16597
true : 32632
[...]

The reason this is a problem is because I'm implementing a crawler kind
of process, that needs to process the files. Sometimes for more than
16s.
I realise that I can set jcifs.smb.client.soTimeout=0 and it will solve
my immediate problem. 
But I fear that this is a generel problem in handeling DFS referals.

-- Martin D. Pedersen


More information about the jcifs mailing list