torrent: Torrent not available after a while when using WebTorrent

I used torrent download -seed 'magnet:?xt=urn:btih:...' to download and then seed the torrent via WebTorrent.

If I try to download the torrent (using instant.io or btorrent.xyz) just after download completes, so after

downloading "...": 288 MB/288 MB, 2197/2197 pieces completed (0 partial)

is printed to the logs, then everything is alright.

But then, after waiting for a while I see the following in the logs:

2020-06-23T11:19:49+0300 INFO  tracker_client.go:100: tracker client for "wss://tracker.btorrent.xyz": websocket instance ended: read message error: websocket: close 1006 (abnormal closure): unexpected EOF
2020-06-23T11:20:32+0300 INFO  tracker_client.go:100: tracker client for "wss://tracker.openwebtorrent.com": websocket instance ended: read message error: websocket: close 1006 (abnormal closure): unexpected EOF

And immediately after those logs, I am unable to download the seeded file via WebTorrent using the websites mentioned above.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (12 by maintainers)

Most upvoted comments

I have tested latest master. The panic and the original issue of this ticket has been fixed.

Thank you very much @DigitalAlchemist and @anacrolix!

Did some digging on this today. Per this file, OpenWebTorrent doesn’t accept messages that aren’t one of:

  • “started”
  • “stopped”
  • “completed”
  • “”

Where “” is an empty or missing field value, and instead throws an exception which kills the socket. https://github.com/OpenWebTorrent/openwebtorrent-tracker/blob/2a8eafab5e29912f69fba4b5ee957941441fe51f/src/FastTracker.h#L56

The array in the below file contains the string “empty” in lieu of an empty string. BEP3 isn’t clear (to me) as to whether this should be the string “empty” or an empty string. I went hunting through the libtorrent source and have deduced it should be an empty string, not the string “empty”. I’m not entirely familiar with this code, so it might be my mistake. https://github.com/anacrolix/torrent/blob/6e43db6a89fbc03b80ebc8b7c31cf50f1165c6a9/tracker/tracker.go#L40

Thoughts?

There’s some other optimizations worth while, which include re-sending offers when the socket falls over, but that’s probably a different issue.

@2m Here a webtorrent tracker is first announced to after a new client reference to the tracker is obtained: https://github.com/anacrolix/torrent/blob/9d0ea150445aa5ecb1f8ab8b3c1176a95a0b03f6/torrent.go#L1358 Here a new announce is made when an answer is received for an offer: https://github.com/anacrolix/torrent/blob/c3696aa5a4a0e3e987fa0b4bb6f347da4b7e991e/webtorrent/tracker_client.go#L301 However here, websocket trackers are reconnected if they are drop, but no reannouncing is done. I’m not sure if Torrents should subscribe for connection events, or the webtorrent.TrackerClient should just reannounce automatically: https://github.com/anacrolix/torrent/blob/c3696aa5a4a0e3e987fa0b4bb6f347da4b7e991e/webtorrent/tracker_client.go#L93

Thanks, I believe the issue is that the client needs to re-announce when it reconnects. Ideally it should re-announce regularly but that logic isn’t as trivial to create.