jcifs 共享枚举超时

jcifs share enumartion timesout

我使用 jcifs 1.3.17 已经有一段时间了,最​​近在从一台特定的 NetApp 机器枚举共享时遇到了一些麻烦。

如果需要,我可以post 网络捕获(pcap 文件)。

例外情况是:

jcifs.util.transport.TransportException: Transport2 timedout waiting for response to SmbComReadAndX[command=SMB_COM_READ_ANDX,received=false,errorCode=0,flags=0x0018,flags2=0xC803,signSeq=0,tid=1,pid=17493,uid=1,mid=16,wordCount=12,byteCount=0,andxCommand=0xFF,andxOffset=0,fid=1,offset=7352,maxCount=1024,minCount=1024,openTimeout=-1,remaining=1024,offset=7352]
    at jcifs.util.transport.Transport.sendrecv(Transport.java:73)
    at jcifs.smb.SmbTransport.send(SmbTransport.java:655)
    at jcifs.smb.SmbSession.send(SmbSession.java:255)
    at jcifs.smb.SmbTree.send(SmbTree.java:113)
    at jcifs.smb.SmbFile.send(SmbFile.java:792)
    at jcifs.smb.SmbFileInputStream.readDirect(SmbFileInputStream.java:181)
    at jcifs.dcerpc.DcerpcPipeHandle.doReceiveFragment(DcerpcPipeHandle.java:99)
    at jcifs.dcerpc.DcerpcHandle.sendrecv(DcerpcHandle.java:220)
    at jcifs.smb.SmbFile.doMsrpcShareEnum(SmbFile.java:1938)
    at jcifs.smb.SmbFile.doShareEnum(SmbFile.java:1851)
    at jcifs.smb.SmbFile.doEnum(SmbFile.java:1797)
    at jcifs.smb.SmbFile.listFiles(SmbFile.java:1773)
    at jcifs.smb.SmbFile.listFiles(SmbFile.java:1762)
    at com.mprv.filecrawler.cifs.SmbRootCrawler.listDirectories(SmbRootCrawler.java:32)
    at com.mprv.filecrawler.cifs.SmbDirCrawler.crawl(SmbDirCrawler.java:62)
    at com.mprv.filecrawler.cifs.SmbDirCrawler.init(SmbDirCrawler.java:38)
    at com.mprv.filecrawler.DirTask.run(DirTask.java:41)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
netShareEnum response status=50
netShareEnum response=NetShareEnumResponse[command=SMB_COM_TRANSACTION,received=false,errorCode=0,flags=0x0098,flags2=0xC801,signSeq=0,tid=1,pid=17493,uid=1,mid=5,wordCount=10,byteCount=5,totalParameterCount=4,totalDataCount=0,parameterCount=4,parameterOffset=56,parameterDisplacement=0,dataCount=0,dataOffset=60,dataDisplacement=0,setupCount=0,pad=1,pad1=0,status=50,converter=0,entriesReturned=16,totalAvailableEntries=0]
jcifs.smb.SmbException: 50
    at jcifs.smb.SmbFile.doNetShareEnum(SmbFile.java:1961)
    at jcifs.smb.SmbFile.doShareEnum(SmbFile.java:1855)
    at jcifs.smb.SmbFile.doEnum(SmbFile.java:1797)
    at jcifs.smb.SmbFile.listFiles(SmbFile.java:1773)
    at jcifs.smb.SmbFile.listFiles(SmbFile.java:1762)
    at com.mprv.filecrawler.cifs.SmbRootCrawler.listDirectories(SmbRootCrawler.java:32)
    at com.mprv.filecrawler.cifs.SmbDirCrawler.crawl(SmbDirCrawler.java:62)
    at com.mprv.filecrawler.cifs.SmbDirCrawler.init(SmbDirCrawler.java:38)
    at com.mprv.filecrawler.DirTask.run(DirTask.java:41)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

更新: 根据 pcap 文件,似乎在某些时候,当收到大量共享时,JCIFS 在 Dcerpc 片段后停止请求更多数据包 (SmbComReadAndX)。

似乎问题出在服务器上的共享数量(~250 共享) Jcifs 缓冲区从 1024 字节增加到 4280 字节。