[jcifs] Exception after ten minutes pooling the shared directory

Erdei Bela ebela at freemail.hu
Tue Sep 20 10:27:15 GMT 2005


Hello!


I wrote a simple test program which just keeps polling a directory in an 
infinite loop.
After ten minutes of running it constantly throws an exception, and 
after that the directory cannot be read again, only after restart.
The watched server is a linux and running samba-3.0.14a-Debian and test 
program is running on windows XP.


Here is the sample:


import hu.dandre.util.fs.JCifsDirectory;
import hu.dandre.util.watcher.DirectoryWatcher;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.naming.directory.InvalidAttributeValueException;

import jcifs.smb.SmbFile;


public class SmbDirWatcher
{
    static long startTime,firstErrorTime,endTime;
   
    public static void main(String args[]) throws 
InvalidAttributeValueException, FileNotFoundException, IOException, 
InterruptedException
    {
        startTime=System.currentTimeMillis();
       
        String smbUrl="smb://username:pass@box/watchedshare/";
        File stopFile=new File("C:\\STOP");
        SmbFile sf=new SmbFile(smbUrl);
       
        System.out.print(sf.getExpiration());
       
        while (! stopFile.exists())
        {
            try
            {
                if (sf.canRead())
                {
                    SmbFile[] sfs=sf.listFiles();
                    for (SmbFile sf1 : sfs)
                    {
                        sf1.canRead();
                    }
                    System.out.print("*");
                    System.out.flush();
                }
                else
                {
                    System.out.print("-");
                    System.out.flush();
                }
            }
            catch (Exception e)
            {
                if (firstErrorTime==0)
                    firstErrorTime=System.currentTimeMillis();

                System.out.print("!");
                System.out.flush();
//                sf = new SmbFile(smbUrl);
                e.printStackTrace();
                stopFile.createNewFile();
            }
            Thread.sleep(2000);
        }
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
       
        System.out.println("start time      : "+sdf.format(new 
Date(startTime)));
        System.out.println("first error time: "+sdf.format(new 
Date(firstErrorTime)));
        System.out.println("end   time      : "+sdf.format(new 
Date(System.currentTimeMillis())));
       
    }
}


And the output:
***********************************************************************************************************************************************************************************************************************************************************************************************************!
jcifs.smb.SmbException:
jcifs.util.transport.TransportException: 
Transport1[DEBIAN<20>/192.168.3.120:445] timedout waiting for response 
to 
Trans2FindFirst2[command=SMB_COM_TRANSACTION2,received=false,errorCode=The 
operation completed 
successfully.,flags=0x0018,flags2=0xC003,signSeq=0,tid=1,pid=4586,uid=100,mid=601,wordCount=15,byteCount=19,totalParameterCount=18,totalDataCount=0,maxParameterCount=10,maxDataCount=65535,maxSetupCount=0,flags=0x00,timeout=0,parameterCount=18,parameterOffset=66,parameterDisplacement=0,dataCount=0,dataOffset=84,dataDisplacement=0,setupCount=1,pad=1,pad1=0,searchAttributes=0x16,searchCount=200,flags=0x00,informationLevel=0x104,searchStorageType=0,filename=\]
    at jcifs.smb.SmbTransport.send(SmbTransport.java:533)
    at jcifs.smb.SmbSession.send(SmbSession.java:228)
    at jcifs.smb.SmbTree.send(SmbTree.java:102)
    at jcifs.smb.SmbFile.send(SmbFile.java:689)
    at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1683)
    at jcifs.smb.SmbFile.listFiles(SmbFile.java:1574)
    at jcifs.smb.SmbFile.listFiles(SmbFile.java:1482)
    at SmbDirWatcher.main(SmbDirWatcher.java:40)

    at jcifs.smb.SmbTransport.send(SmbTransport.java:559)
    at jcifs.smb.SmbSession.send(SmbSession.java:228)
    at jcifs.smb.SmbTree.send(SmbTree.java:102)
    at jcifs.smb.SmbFile.send(SmbFile.java:689)
    at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1683)
    at jcifs.smb.SmbFile.listFiles(SmbFile.java:1574)
    at jcifs.smb.SmbFile.listFiles(SmbFile.java:1482)
    at SmbDirWatcher.main(SmbDirWatcher.java:40)

start time      : 2005.09.20 12:11:14
first error time: 2005.09.20 12:21:23
end   time      : 2005.09.20 12:21:25



More information about the jcifs mailing list