File Transfer

Hi all.

I have a file transfer class which has been part of the development of my

program for some time. It now no longer works and i am at a loss to

explain why this has happened. The code itself has changed little, aside from

some progress monitoring additions. Two things that have changed are 1) i

am using my own OpenFire Server as apposed to the public Jabber.org server and

  1. i upgraded to smack 3.0.4 from 2.2.x. I don’t know if this affects anything

but i thought i’d better mention it. I have seen forum posts regarding this issue and

have disabled the proxy service as advised, this made no difference. Incidentally, i temporarily reverted to the jabber.org

server to test a file transfer scenario. This also failed which

leaves me to believe the problem is not because of the openfire server setup but as a result of my code or the upgrade to Smack 3.0.4

The behaviour of a typical file transfer is this:

  • The first file transfer
    from a to b will work in all circumstances.

  • The second file transfer
    from a to b may work although it is possible and increasingly
    common that it will simply hang and then fail

  • The first file
    transfer between b to a after a to b’s initial transfer may work, or it
    may hang and then fail. The failing outcome is far more likely.

Is there something fundamental i am missing? do the streams need to be

flushed or closed in some way? i have not found the mechanism to do this in the

docs if this is the case.

Any pointers would be greatly appreciated.

Thanks and regards,

Steven

BTW

I thought i had better add that i am using files as apposed to streams. i

tried using the sendfile method which returns an outputstream and flushed

and closed the stream where necessary. This changed very little.

Again, any help would be great.

Thanks

Steven

see below

Message was edited by: steven_s

Hi all.

Ok, I have got around this issue. The problem seems to be caused by the IncomingFileTransfer .isDone() method. This method never seems to return true and so when used in a while loop, gets stuck in an infinite loop.

My solution (though perhaps not the best solution) was to use the progress of the transfer as a argument in the while loop.

like so:

int intprogress=0;

double progress=0.0;

while(intprogress!=100) {

Thread.sleep(10);

progress=incomingTransfer.getProgress();

intprogress=(int)(progress * 100d);

}

As i said, not sure if this is the best solution but it solved my problem.

Thanks

Steven