File transfer issue

Hi,

I’‘m currently testing the file transfert feature and i’'ve got a small issue…i can receive a file but the getStatus() of the IncomingFileTransfert object always return “In Progress”, even when the transfert is complete

I’‘ve tried to use the online example , had a look in Spark’‘s code too…didn’‘t see any big difference,i can’‘t really see where i’'m wrong…

here’'s a sample of my test code:

IncomingFileTransfer transfer = request.accept();

try {

final File downloadedFile = new File(“C:
receive”, request.getFileName());

transfer.recieveFile(downloadedFile);

FileTransfer.Status status ;

while (true) {

status = transfer.getStatus();

if (status == FileTransfer.Status.error ||
status == FileTransfer.Status.complete || status == FileTransfer.Status.cancelled || status == FileTransfer.Status.refused) {

System.out.println(“transfer ok”);

break;

}

if(transfer.getStatus().equals(Status.error)) {

System.out.println("ERROR!!! " + transfer.getError());

} else {

System.out.println(transfer.getAmountWritten());

System.out.println(transfer.getStatus());

System.out.println(transfer.getProgress());

}

sleep(1000);

}

Any idea?

Thanxs

Message was edited by: Max31

Hi,

I could reproduce this problem when using IBB filetransfer.

FIX1: Use SOCKS5 transfer only, it will complete.

FIX2: Use transfer.isDone() || getProgress() == 1D (in my test, the progress always upodated).

FIX3: Seens that the close connection IQ is never received or processed by the receiver or never sent, I could not debug now what is happening, but a VM dump shows that the receiver thread is running and the IBBInputStream is executing the loadBufferWait() and since there is no packet to be received, nextResult(1000) is always returning null. A timeout mechanism should stop the thread to be kept in this loop (I implemented this changing the close() behaviour). But to know what is happening to the close packet will trully fix your issue.

I will trace the connection and debug smack code tomorrow to understand what is happening with the Close IQ.

TIP: Use transfer.isDone() instead getStatus == error && getStatus() = complete && getStatus() == …

Smack is okay, I found the problem in our application…

You should return ASAP from the fileTransferRequest method. Since this method is a notify from a process packet filter, if you hold it (doing a while transfer.getStatus()), no other process packet filter is processed (like when the Close IQ is received).

So, give the IncomingFileTransfer to a thread outside the method fileTransferRequest and there you make the transfer.getStatus() loop.

Cheers,

Matheus G.

This should definitely go into the Smack documentation (on http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/ index.html that is). I did the same mistake here.