[jcifs] TransportException executing SmbFile.length() - delay dependent

Filip Orelj chicholinac at yahoo.com
Wed Sep 21 12:44:03 GMT 2005


Hi Mike,

here is simplified code which also causes the same
exc.

- - - - - - - - - - 
package com.fkbase.jcifs;
/*
 * - writes lines to a file using jCifs library
 * - set your username, password, sleepInMillis -
hardcoded 
 * - command line argument is path to file: e.g.
//machine/share/folder/filename
 */

import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;

import jcifs.smb.SmbException;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;


public class JcifsWriter {

  String userName = "YOUR USERNAME";
  String password = "YOUR PASSWORD";
  static long sleepInMillis = 1000L;// 10L, 1000L, 5 *
60 * 1000L

	PrintWriter outPrintWriter;
	SmbFileOutputStream fileOutStream;
  SmbFile file;
  String errors = null;
  JcifsWriter jCifsWriter;
  long fileLength = 0L;
  static int maxCounter = 20000;
  static long maxFileSize = 500000L;
   
  public JcifsWriter(String fileNameFullPath)
	{
    try {
    	fileNameFullPath = getSmbFullPath( userName,
password, fileNameFullPath );
    	file = new SmbFile( fileNameFullPath );
			fileOutStream = new SmbFileOutputStream( file, true
);
			outPrintWriter = new PrintWriter( fileOutStream,
true );
		}
		catch ( MalformedURLException murle ) {
			errors = murle.getMessage();
			murle.printStackTrace();
		}
		catch ( SmbException smbe ) {
			errors = smbe.getMessage();
			smbe.printStackTrace();
		}
		catch ( UnknownHostException uhe ) {
			errors = uhe.getMessage();
			uhe.printStackTrace();
		}
	}
    
	public static void main( String[] args )
	{
		SimpleDateFormat dateFormatter = new
SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		int counter = 0;
		JcifsWriter jCifsWriter = new JcifsWriter( args[0]
); 
		
		System.out.println("Writing started at  " +
dateFormatter.format( new Date(
System.currentTimeMillis() )));
		while ( counter < maxCounter &&
jCifsWriter.getFileLength() < maxFileSize )
		{
			counter++;
			try {
				Thread.sleep( sleepInMillis );
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			String lineStr = "This is line number : " +
counter;
			jCifsWriter.writeLineToFile( lineStr );
		}
		System.out.println("Writing ended at  " +
dateFormatter.format( new Date(
System.currentTimeMillis() )));
	}
	

	public long getFileLength() {
		return fileLength;
	}

	private void writeLineToFile( String
_eventLineToWrite ) {
		try {
			outPrintWriter.println( _eventLineToWrite );
			fileLength = file.length();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
  }
	
	public static String getSmbFullPath(String userName,
String password, String fileNamePath) {
		String smbFullPath = "smb://" + userName + ":" +
password + "@" + fileNamePath.substring(2);
		return smbFullPath; 
	}
	
}

- - - - - - - - - - - - 

Thanks,

Filip



--- Michael B Allen <mba2000 at ioplex.com> wrote:

> Can you send me the program so I can reproduce?
> 
> On Sat, 17 Sep 2005 07:33:42 -0700 (PDT)
> Filip Orelj <chicholinac at yahoo.com> wrote:
> 
> > Hi, 
> > 
> > trying out jcifs (1.2.3) I encountered pretty
> strange
> > exception (on linux).
> > I write particular lines to a text file using
> > different values for delays. 
> > With delay values out of -1 line per second- range
> > everything works fine, but for values close to the
> > range, the Exception below appears after approx.
> 200k
> > of written data, trying execute SmbFile.length().
> > (BTW, the same code works fine writing lines every
> 15
> > min. as well as 10 lines/sec.)
> > 
> > Any idea?
> > 
> > trace:
> > jcifs.util.transport.TransportException:
> > Transport7[filipovlin/192.168.0.1:139] timedout
> > waiting for response to
> >
>
Trans2QueryPathInformation[command=SMB_COM_TRANSACTION2,received=false,errorCode=The
> > operation completed
> >
>
successfully.,flags=0x0018,flags2=0x4003,signSeq=0,tid=1,pid=64329,uid=100,mid=858,wordCount=15,byteCount=41,totalParameterCount=40,totalDataCount=0,maxParameterCount=2,maxDataCount=40,maxSetupCount=0,flags=0x00,timeout=0,parameterCount=40,parameterOffset=66,parameterDisplacement=0,dataCount=0,dataOffset=106,dataDisplacement=0,setupCount=1,pad=1,pad1=0,informationLevel=0x102,filename=\2\TestFile2.tx5]
> > 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:688)
> > at jcifs.smb.SmbFile.queryPath(SmbFile.java:1196)
> > at jcifs.smb.SmbFile.length(SmbFile.java:2142)
> > at
> >
>
com.fkbase.jcifs.JcifsWriter.writeLineToFile(JcifsWriter.java:250)
> > 
> > 
> > Thanks,
> > Filip
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> > http://mail.yahoo.com 
> > 
> 



		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


More information about the jcifs mailing list