Search code examples
javaudpbittorrent

How can I scrape a udp BitTorrent tracker in Java?


I send a scrape packet, seeders, downloaders and leechers always return as 0.

Here is my initial connection and scraper code.

public void scrape() {
        for (final String infohash : infoHashes) {
            hashes += infohash;
        }
        outStream.writeByte(hashes.getBytes());

}

For example my output is

3617635676834215396 0


Solution

  • for (final String infohash : infoHashes) {
        hashes += infohash;
    }
    outStream.writeByte(hashes.getBytes());
    

    My guess is that you're using hex-encoded hashes. UDP scrapes expect them in their raw format.