[jcifs] Connection Failure using jcifs

ludwig ludz_lim at yahoo.com
Tue Aug 11 03:51:59 MDT 2009


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");
		
		
		File log = new File("C:\\egg.log");
		PrintStream strm;
		try {
			 strm = new PrintStream(log);
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
			return;
		}
		LogStream.setLevel(10);

		LogStream.setInstance(strm);
		
	
	

		
		try {
			String
str="smb://asiapacific;$bom:tQmH24wnHE8m@test.asiapacific.corp.net/Auto
Release Testing";

			FileInputStream src = new FileInputStream("c:\\a.txt");
			

			SmbFileOutputStream output = new SmbFileOutputStream(str+"/"+"b.txt");
			byte arr[]  = new byte[1024];
			src.read(arr);
			//System.out.println(arr);
			output.write(arr);
			output.flush();
			output.close();
			src.close();
		
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println(e.getMessage());
		}


	}

}


    Here's the stack trace of the program
    ===========================


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)
	at jcifs.smb.SmbTree.treeConnect(SmbTree.java:141)
	at jcifs.smb.SmbFile.doConnect(SmbFile.java:899)
	at jcifs.smb.SmbFile.connect(SmbFile.java:942)
	at jcifs.smb.SmbFile.connect0(SmbFile.java:868)
	at jcifs.smb.SmbFile.open0(SmbFile.java:958)
	at jcifs.smb.SmbFile.open(SmbFile.java:992)
	at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:142)
	at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:97)
	at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:82)
	at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:54)
	at TestCifs.test(TestCifs.java:58)
	at TestCifs.main(TestCifs.java:11)

	at jcifs.smb.SmbTransport.connect(SmbTransport.java:296)
	at jcifs.smb.SmbTree.treeConnect(SmbTree.java:141)
	at jcifs.smb.SmbFile.doConnect(SmbFile.java:899)
	at jcifs.smb.SmbFile.connect(SmbFile.java:942)
	at jcifs.smb.SmbFile.connect0(SmbFile.java:868)
	at jcifs.smb.SmbFile.open0(SmbFile.java:958)
	at jcifs.smb.SmbFile.open(SmbFile.java:992)
	at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:142)
	at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:97)
	at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:82)Failed
to connect: test.asiapacific.corp.net/16.158.112.18

	at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:54)
	at TestCifs.test(TestCifs.java:58)
	at TestCifs.main(TestCifs.java:11)

    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..... |

   Thanks in advance.

Regards,
Ludwig

-- 
View this message in context: http://www.nabble.com/Connection-Failure-using-jcifs-tp24914664p24914664.html
Sent from the Samba - jcifs mailing list archive at Nabble.com.



More information about the jcifs mailing list