Getting 404 fetching from the tracker URL

I’m stuck on Stage Discover peers #fi9

I have tried fetching from the tracker server url using the following url : http://bittorrent-test-(mentioned in the comments below

But it gives me a 404 not found error.

And here’s a snippet of my code:

is my infohash correct ?

//http://bittorrent-test-tracker.codecrafters.io/announce/info_hash=%d6%9f%91%e6%b2%ae%4c%54%24%68%d1%07%3a%71%d4%ea%13%87%9a%7f&peer_id=-PC0001-B1A6OIvyXa9I&port=6881&uploaded=0&downloaded=0&left=92063&compact=1

else if (command === "peers") {
    const filePath = process.argv[3]
    const obj = await infoTorrent(filePath)
    const trackerUrl = obj.announce

    const bencodedInfo = bencode(obj.info)
    const hexInfo = Buffer.from(bencodedInfo, "binary")
    const infoHash = calculateSHA1(hexInfo)
    console.log("infohash", uriEncodeInfoHash(infoHash))

    const params = new URLSearchParams({
      info_hash : uriEncodeInfoHash(infoHash),
      peer_id : generatePeerId(),
      port : 6881,
      uploaded : 0,
      downloaded : 0,
      left: obj.info.length,
      compact : 1
    });
    console.log(`${obj.announce}/${decodeURIComponent(params.toString())}`)
    const response = await fetch(`${obj.announce}/${decodeURIComponent(params.toString())}`);
    const res = await response.json() 
    // console.log("res")
  }

Hey @abhishek-7901, here’s an issue you can address first:

:cross_mark: http://[omitted]/announce/info_hash=[omitted]
:white_check_mark: http://[omitted]/announce?info_hash=[omitted]

Here’s a correct URL for reference:

http://bittorrent-test-tracker.codecrafters.io/announce?info_hash=%C7x%29%D2%A7%7De%16%F8%8C%D7%A3%DE%1A%26%AB%CB%FA%B0%DB&peer_id=CA0TJ4VAAL4XJ5HM5YTA&port=6881&uploaded=0&downloaded=0&left=2994120&compact=1

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.