Closed lalkmim closed 8 years ago
I have the same issue. Do you have any solutions?
I had to stop the project where I was using ttorrent, but I believe you can workaround the problem by adding the same torrent file. It'll start as a new one, but won't lose the progress made previously. If you try to use the same torrent file already on disk, you get the problem.
I've spent some time working on this, and as far as I can tell it's something to do with the BitfieldMessage.
It only shows itself when there's a torrent that has at least some of the progress - and when it sends the piece list to other clients.
I've had it resume successfully when I replaced the call in PeerExchange.java with this:
for (int i = pieces.nextSetBit(0); i >= 0; i = pieces.nextSetBit(i+1)) {
this.send(PeerMessage.HaveMessage.craft(i));
}
Any more info on this? I can also reproduce the error.
I am also getting this exception:
Thread [bt-serve] (Suspended (exception IllegalArgumentException)) ByteBuffer.allocate(int) line: 334 ConnectionHandler.validateHandshake(SocketChannel, byte[]) line: 381 ConnectionHandler.accept(SocketChannel) line: 301 ConnectionHandler.run() line: 248 Thread.run() line: 745
The ByteBuffer is trying to allocate a negative capacity.
The bitfield payload in the bitfield message is truncated to the highest bit that is set. As a consequence the bitfield does not cover all pieces in most cases and therefore peers drop the connection. This prevents a successful resume of downloads.
Thanks @henkel for the patch! Closing this.
I'm trying to embed your torrent library on a android application. It's working very well but I'm facing a problem whenever I try to resume the download of a torrent that were forced to stop due to the application being closed.
What the program does is: 1) Starts downloading of a torrent file; 2) It starts fine and is downloading correctly; 3) Application is closed 4) Application is reopened 5) We (re)start the torrent that were stopped before 6) It runs correctly until the point where he tries to read messages from the peers (log below)
The problem below is happening to all peers, and that happens before anything is downloaded, no piece is completed.
Log of only this peer:
Log when it runs correctly (first time):
Full log: