[jcifs] Connection Failure using jcifs

Michael B Allen ioplex at gmail.com
Tue Aug 11 12:03:11 MDT 2009


On Tue, Aug 11, 2009 at 5:51 AM, ludwig<ludz_lim at yahoo.com> wrote:
>
> Hi:
>
>    I was experimenting with JCIFS, I'm experiencing difficulties in writing
> to a shared folder (running Win 2003). I can only connect and write to the
> shared drive only 10% of the time. The file that I write is just a very
> small text file (just 1 line for testing purposes).  Another surprising
> thing is, "ping" does not report any connectivity problem. The ping time is
> around 3 to 6 ms. I already set the timeout to 150000 MS (15 seconds) but I
> still get a timeout problem
>
>    JCIFS version :  1.3.11
>    JRE version :      6
>
>   Here is the source code:
> ==========================
> public class TestCifs {
>
>        public static void main(String[] args) {
>
>        TestCifs.test();
>
>
>        }
>        /**
>         * @param args
>         */
>        public static void test() {
>
>
>
>                jcifs.Config.setProperty( "jcfis.resolveOrder","DNS");
>                jcifs.Config.setProperty( "jcifs.util.loglevel","10");
>                jcifs.Config.setProperty( "jcifs.netbios.retryTimeout", "150000");
>                jcifs.Config.setProperty("jcifs.smb.client.responseTimeout", "150000");
>                jcifs.Config.setProperty("jcifs.smb.client.soTimeout","150000");
>                jcifs.Config.setProperty("jcifs.smb.client.dfs.disabled","true");
>                jcifs.Config.setProperty("jcifs.smb.client.signingPreferred", "true");
>                jcifs.Config.setProperty("jcifs.smb.client.attrExpirationPeriod", "0");
>                jcifs.Config.setProperty("jcifs.netbios.cachePolicy","0");
>                jcifs.Config.setProperty("jcifs.smb.client.dfs.strictView", "true");

Hi Ludwig,

You should start by removing all of the above properties.

> jcifs.smb.SmbException: Failed to connect:
> test.asiapacific.corp.net/16.158.112.18
> jcifs.util.transport.TransportException: Connection timeout
>        at jcifs.util.transport.Transport.connect(Transport.java:178)
>        at jcifs.smb.SmbTransport.connect(SmbTransport.java:294)

This is a pretty low-level networking error that basically just means
JCIFS could not establish a socket with that server.

If it only works 10% of the time that is a very important clue.

I suspect the server has multiple IPs and all but 1/10th of them are
firewalled or not accessible from the network you're running JCIFS on.

>    Here is the content of the log:
>    ========================
> doConnect: test.asiapacific.corp.net/16.158.112.18
> session established ok with test.asiapacific.corp.net/16.158.112.18
> SmbComNegotiate[command=SMB_COM_NEGOTIATE,received=false,errorCode=0,flags=0x0018,flags2=0xC807,signSeq=0,tid=0,pid=2031,uid=0,mid=1,wordCount=0,byteCount=12,wordCount=0,dialects=NT
> LM 0.12]
> 00000: FF 53 4D 42 72 00 00 00 00 18 07 C8 00 00 00 00  |SMBr......?...|
> 00010: 00 00 00 00 00 00 00 00 00 00 EF 07 00 00 01 00  |..........?....|
> 00020: 00 0C 00 02 4E 54 20 4C 4D 20 30 2E 31 32 00     |....NT LM 0.12. |
>
> New data read: Transport1[test.asiapacific.corp.net/16.158.112.18:139]
> 00000: FF 53 4D 42 72 00 00 00 00 98 07 C8 00 00 00 00  |SMBr......?...|
> 00010: 00 00 00 00 00 00 00 00 00 00 EF 07 00 00 01 00  |..........?....|
>
> byteCount=120 but readBytesWireFormat returned 0
> SmbComNegotiateResponse[command=SMB_COM_NEGOTIATE,received=false,errorCode=0,flags=0x0098,flags2=0xC807,signSeq=0,tid=0,pid=2031,uid=0,mid=1,wordCount=17,byteCount=120,wordCount=17,dialectIndex=0,securityMode=0x3,security=user,encryptedPasswords=true,maxMpxCount=50,maxNumberVcs=1,maxBufferSize=16644,maxRawSize=65536,sessionKey=0x00000000,capabilities=0x8001F3FD,serverTime=Tue
> Aug 11 17:27:09 CST
> 2009,serverTimeZone=65056,encryptionKeyLength=0,byteCount=120,oemDomainName=]
> 00000: FF 53 4D 42 72 00 00 00 00 98 07 C8 00 00 00 00  |SMBr......?...|
> 00010: 00 00 00 00 00 00 00 00 00 00 EF 07 00 00 01 00  |..........?....|
> 00020: 11 00 00 03 32 00 01 00 04 41 00 00 00 00 01     |....2....A..... |

Clearly this does not correspond to the stack trace above since you
are establishing a socket and actually receiving an
SMB_COM_NETGOTIATE_ANDX_RESPONSE. I guess this is one of the 10% that
worked.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jCIFS mailing list