# \#challenge:bittorrent

**URL:** https://forum.codecrafters.io/tag/challenge-bittorrent/7.md

[Latest](https://forum.codecrafters.io/latest.md) · [Categories](https://forum.codecrafters.io/categories.md) · [Tags](https://forum.codecrafters.io/tags.md)

---

## [Invalid Peer Response](https://forum.codecrafters.io/t/invalid-peer-response/16276)

<div class="topic-metadata">

**Author:** [@thestuckster](https://forum.codecrafters.io/u/thestuckster)\
**Replies:** 1\
**Last updated:** [September 12, 2026, 1:36pm UTC](https://forum.codecrafters.io/t/invalid-peer-response/16276 "2026-09-12T13:36:14Z")

</div>

When doing the download a piece challenge the tracker isn’t returning a valid response \[your\_program\] Raw response body: d8:completei0e10:incompletei1e8:intervali60e12:min intervali60ee \[your\_program\] Unmarshalled resp…

---

## [\#BF7 Bittorrent challenge: torrent not found](https://forum.codecrafters.io/t/bf7-bittorrent-challenge-torrent-not-found/15692)

<div class="topic-metadata">

**Author:** [@natalka1122](https://forum.codecrafters.io/u/natalka1122)\
**Replies:** 2\
**Last updated:** [May 31, 2026, 6:11pm UTC](https://forum.codecrafters.io/t/bf7-bittorrent-challenge-torrent-not-found/15692 "2026-05-31T18:11:29Z")

</div>

It looks like test torrent is gone from the anouncer. For my request it answers Dict({'failure reason': String(b'torrent not found')}) It started a few hours ago. I passed this stage days ago, but now codecrafters tes…

---

## [New in Scala track: BitTorrent challenge + v3.8 Support](https://forum.codecrafters.io/t/new-in-scala-track-bittorrent-challenge-v3-8-support/16034)

<div class="topic-metadata">

**Author:** [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Replies:** 0\
**Last updated:** [April 6, 2026, 10:38pm UTC](https://forum.codecrafters.io/t/new-in-scala-track-bittorrent-challenge-v3-8-support/16034 "2026-04-06T22:38:37Z")

</div>

Hey everyone! The Scala track now includes the Build your own BitTorrent challenge. We’ve also upgraded Scala to version 3.8 across all supported challenges. Ready to put your Scala skills to the test? Jump into the S…

---

## [Can we have some extension updates for bittorrent?](https://forum.codecrafters.io/t/can-we-have-some-extension-updates-for-bittorrent/15239)

<div class="topic-metadata">

**Author:** [@fralligator](https://forum.codecrafters.io/u/fralligator)\
**Replies:** 2\
**Last updated:** [March 18, 2026, 2:33pm UTC](https://forum.codecrafters.io/t/can-we-have-some-extension-updates-for-bittorrent/15239 "2026-03-18T14:33:57Z")

</div>

Hello there The BitTorrent challenge is one of the challenges from which I learned the most techniques. I wonder if you guys could start pushing some extensions to it? I get you probably focus on the Redis challenge sin…

---

## [\[Bittorent\] \[magnet\_link\] \[Receive extension handshake #jk6\] Getting timeout when receive message length](https://forum.codecrafters.io/t/bittorent-magnet-link-receive-extension-handshake-jk6-getting-timeout-when-receive-message-length/15961)

<div class="topic-metadata">

**Author:** [@mrThinBone](https://forum.codecrafters.io/u/mrThinBone)\
**Replies:** 1\
**Last updated:** [March 4, 2026, 6:07pm UTC](https://forum.codecrafters.io/t/bittorent-magnet-link-receive-extension-handshake-jk6-getting-timeout-when-receive-message-length/15961 "2026-03-04T18:07:40Z")

</div>

I passed Send extension handshake #xi4. But with #jk6 stage, when trying to receive message length recv(sock, buffer, 4, 0) I’m getting timeout sometimes then failed a test case, sometimes it just works and I can receiv…

---

## [Can't Download a Piece due to Connection Issues](https://forum.codecrafters.io/t/cant-download-a-piece-due-to-connection-issues/15861)

<div class="topic-metadata">

**Author:** [@MaHmoudHaBlaSs](https://forum.codecrafters.io/u/MaHmoudHaBlaSs)\
**Replies:** 3\
**Last updated:** [February 5, 2026, 12:09am UTC](https://forum.codecrafters.io/t/cant-download-a-piece-due-to-connection-issues/15861 "2026-02-05T00:09:45Z")

</div>

I’m stuck on Stage #ND2. I’m stuck in downloading the piece, for the first test of piece\_0 the code works well and download all blocks, but at the second test of piece\_11 there is a problem with peers’ connection. I ha…

---

## [Can't extract length from torrent file](https://forum.codecrafters.io/t/cant-extract-length-from-torrent-file/15807)

<div class="topic-metadata">

**Author:** [@MaHmoudHaBlaSs](https://forum.codecrafters.io/u/MaHmoudHaBlaSs)\
**Replies:** 2\
**Last updated:** [January 19, 2026, 7:21pm UTC](https://forum.codecrafters.io/t/cant-extract-length-from-torrent-file/15807 "2026-01-19T19:21:56Z")

</div>

I’m stuck on Stage #OW9 The expected output length is 820892 while the sample.torrent file has length equal to 92063 as described in the stage explanation, so it keeps failing on tests… Here are my logs: And here’s…

---

## [Challenge QV6 bittorrent](https://forum.codecrafters.io/t/challenge-qv6-bittorrent/15649)

<div class="topic-metadata">

**Author:** [@yashraizb](https://forum.codecrafters.io/u/yashraizb)\
**Replies:** 2\
**Last updated:** [December 14, 2025, 7:45am UTC](https://forum.codecrafters.io/t/challenge-qv6-bittorrent/15649 "2025-12-14T07:45:45Z")

</div>

My code is getting timed out after downloading 5 to 6 blocks of a piece using a magnet link. this is my commit of github https://github.com/yashraizb/codecrafters-bittorrent-python/commit/2cb968d587327a701d310ca3b6fd762…

---

## [Bittorrent tracker returns invalid Bencoded responses](https://forum.codecrafters.io/t/bittorrent-tracker-returns-invalid-bencoded-responses/15614)

<div class="topic-metadata">

**Author:** [@benjamingeer](https://forum.codecrafters.io/u/benjamingeer)\
**Replies:** 2\
**Last updated:** [December 3, 2025, 8:41am UTC](https://forum.codecrafters.io/t/bittorrent-tracker-returns-invalid-bencoded-responses/15614 "2025-12-03T08:41:41Z")

</div>

I’m doing the Bittorrent challenge in Rust. In stage #JV8, I’ve found that the tracker’s response contains invalid Bencoded data about half the time. I received a response from the tracker containing these bytes: b"d12:…

---

## [Go Torrent File Download Exceeding Time Limit](https://forum.codecrafters.io/t/go-torrent-file-download-exceeding-time-limit/15560)

<div class="topic-metadata">

**Author:** [@revtheundead](https://forum.codecrafters.io/u/revtheundead)\
**Replies:** 3\
**Last updated:** [November 24, 2025, 6:09pm UTC](https://forum.codecrafters.io/t/go-torrent-file-download-exceeding-time-limit/15560 "2025-11-24T18:09:12Z")

</div>

I’m stuck on Stage #JV8. I’ve tried using using a connection pool for each download worker and using pointers to data in channels but the download still seems to be very slow. Here is the main download function: func …

---

## [Discover peers, code don't run](https://forum.codecrafters.io/t/discover-peers-code-dont-run/15534)

<div class="topic-metadata">

**Author:** [@miguelBarreiro85](https://forum.codecrafters.io/u/miguelBarreiro85)\
**Replies:** 2\
**Last updated:** [November 17, 2025, 6:42pm UTC](https://forum.codecrafters.io/t/discover-peers-code-dont-run/15534 "2025-11-17T18:42:40Z")

</div>

It seems the test is expecting some response.txt in my filesystem, don’t know why \[compile\] Compilation successful. Debug = true \[tester::#FI9\] Running tests for Stage #FI9 (Discover peers) \[tester::#FI9\] Couldn’t co…

---

## [\#CA4 cannot connect to peer](https://forum.codecrafters.io/t/ca4-cannot-connect-to-peer/15348)

<div class="topic-metadata">

**Author:** [@GratG](https://forum.codecrafters.io/u/GratG)\
**Replies:** 3\
**Last updated:** [September 28, 2025, 7:11pm UTC](https://forum.codecrafters.io/t/ca4-cannot-connect-to-peer/15348 "2025-09-28T19:11:00Z")

</div>

Hello, I am working with Qt so sorry if that brings other issues But I am working through the stage to perform the handshake and cannot connect to the peer correctly, I am using a QTcpSocket and the same ip:socket as in…

---

## [\#NV6 Why the same stage, in the nv6 stage in cant work?](https://forum.codecrafters.io/t/nv6-why-the-same-stage-in-the-nv6-stage-in-cant-work/15247)

<div class="topic-metadata">

**Author:** [@mmjwxbc](https://forum.codecrafters.io/u/mmjwxbc)\
**Replies:** 4\
**Last updated:** [September 10, 2025, 5:26pm UTC](https://forum.codecrafters.io/t/nv6-why-the-same-stage-in-the-nv6-stage-in-cant-work/15247 "2025-09-10T17:26:51Z")

</div>

else if(command == "magnet\_info") { string magnet\_link = argv\[2\]; auto key\_val = parse\_magnet(magnet\_link); vector\<string\> ips; vector\<uint16\_t\> ports; handle\_magnet\_peers(key\_val\["tr"\], key\_val\["xt"\]…

---

## [Handshake failed occasionally in #nd2 (download a piece)](https://forum.codecrafters.io/t/handshake-failed-occasionally-in-nd2-download-a-piece/14882)

<div class="topic-metadata">

**Author:** [@realth000](https://forum.codecrafters.io/u/realth000)\
**Replies:** 2\
**Last updated:** [August 18, 2025, 8:01am UTC](https://forum.codecrafters.io/t/handshake-failed-occasionally-in-nd2-download-a-piece/14882 "2025-08-18T08:01:48Z")

</div>

The handshake step in stage #nd2 sometimes break when running test online. If I run test offline with \`./your\_program.sh download\_piece …\` it is more likely to get the same error. I do not know if it’s a network issue,…

---

## [Error while passing tests for bencoded Integer, in the bittorrent challenge](https://forum.codecrafters.io/t/error-while-passing-tests-for-bencoded-integer-in-the-bittorrent-challenge/14618)

<div class="topic-metadata">

**Author:** [@vansh-goel](https://forum.codecrafters.io/u/vansh-goel)\
**Replies:** 1\
**Last updated:** [August 10, 2025, 5:01am UTC](https://forum.codecrafters.io/t/error-while-passing-tests-for-bencoded-integer-in-the-bittorrent-challenge/14618 "2025-08-10T05:01:06Z")

</div>

fn decode\_bencoded\_value(encoded\_value: &str) -\> serde\_json::Value { let encoded\_value = encoded\_value.trim(); // If encoded\_value starts with a digit, it's a number if encoded\_value.chars().next().unwrap().i…

---

## [C++ #ND2 challenge build time is taking so much that it causes the time to exceed](https://forum.codecrafters.io/t/c-nd2-challenge-build-time-is-taking-so-much-that-it-causes-the-time-to-exceed/14041)

<div class="topic-metadata">

**Author:** [@ycsvenom](https://forum.codecrafters.io/u/ycsvenom)\
**Replies:** 7\
**Last updated:** [August 1, 2025, 7:04pm UTC](https://forum.codecrafters.io/t/c-nd2-challenge-build-time-is-taking-so-much-that-it-causes-the-time-to-exceed/14041 "2025-08-01T19:04:59Z")

</div>

I’m stuck on Stage #ND2. My sole problem is that when I try to test my code it always exceeds the time. because all the time taken by building step, which weirdly is included in the test time Here are my logs: \[compil…

---

## [No logs in test and submit](https://forum.codecrafters.io/t/no-logs-in-test-and-submit/13500)

<div class="topic-metadata">

**Author:** [@goat-914](https://forum.codecrafters.io/u/goat-914)\
**Replies:** 5\
**Last updated:** [July 23, 2025, 1:11pm UTC](https://forum.codecrafters.io/t/no-logs-in-test-and-submit/13500 "2025-07-23T13:11:00Z")

</div>

When I try to run codecrafters test command I don’t see any logs with tests Initiating test run... ⚡ This is a turbo test run. https://codecrafters.io/turbo Running tests. Logs should appear shortly... stream logs: s…

---

## [Is there a way to retest refactored code on earlier sub-challenges](https://forum.codecrafters.io/t/is-there-a-way-to-retest-refactored-code-on-earlier-sub-challenges/13228)

<div class="topic-metadata">

**Author:** [@dhruvgupta1999](https://forum.codecrafters.io/u/dhruvgupta1999)\
**Replies:** 1\
**Last updated:** [July 8, 2025, 9:45am UTC](https://forum.codecrafters.io/t/is-there-a-way-to-retest-refactored-code-on-earlier-sub-challenges/13228 "2025-07-08T09:45:59Z")

</div>

I refactored my code and it fails on the sub-challenge “download file” in Torrent client project. I want to retest it on the earlier sub-challenges test cases like “download a file piece”. I am using windows so unable …

---

## [Bittorrent, peer handshake response is painfully slow. #ca4](https://forum.codecrafters.io/t/bittorrent-peer-handshake-response-is-painfully-slow-ca4/12567)

<div class="topic-metadata">

**Author:** [@Direwolfesp](https://forum.codecrafters.io/u/Direwolfesp)\
**Replies:** 7\
**Last updated:** [June 24, 2025, 4:23pm UTC](https://forum.codecrafters.io/t/bittorrent-peer-handshake-response-is-painfully-slow-ca4/12567 "2025-06-24T16:23:47Z")

</div>

Hi, I already completed the Peer Handshake stage however I noticed I have to wait around 2 minutes for the peer to response. Is this some normal behaviour or am I doing something wrong? pd: im doing it in zig and these…

---

## [Right hash for sample.torrent, get error when pushing to the git repo](https://forum.codecrafters.io/t/right-hash-for-sample-torrent-get-error-when-pushing-to-the-git-repo/12491)

<div class="topic-metadata">

**Author:** [@jb-san](https://forum.codecrafters.io/u/jb-san)\
**Replies:** 2\
**Last updated:** [June 24, 2025, 1:23pm UTC](https://forum.codecrafters.io/t/right-hash-for-sample-torrent-get-error-when-pushing-to-the-git-repo/12491 "2025-06-24T13:23:41Z")

</div>

I’m stuck on Stage #RB2. when calculating the hash of the sample.torrent, I get the correct result. I wanted to try to do my own encoding and decoding, but when I upload I get the wrong hash here is a repo with the co…

---

## [\[BitTorrent\] How to pass the first stage?](https://forum.codecrafters.io/t/bittorrent-how-to-pass-the-first-stage/12219)

<div class="topic-metadata">

**Author:** [@Swayam-arora-2004](https://forum.codecrafters.io/u/Swayam-arora-2004)\
**Replies:** 2\
**Last updated:** [June 22, 2025, 5:17am UTC](https://forum.codecrafters.io/t/bittorrent-how-to-pass-the-first-stage/12219 "2025-06-22T05:17:51Z")

</div>

Checklist: :white\_check\_mark: or :cross\_mark:: I’ve uncommented the code. :white\_check\_mark: or :cross\_mark:: I’ve saved the changes. :white\_check\_mark: or :cross\_mark:: I’ve run the git commands: git comm…

---

## [Timeout error for #JV8](https://forum.codecrafters.io/t/timeout-error-for-jv8/11833)

<div class="topic-metadata">

**Author:** [@ptrhcpang](https://forum.codecrafters.io/u/ptrhcpang)\
**Replies:** 3\
**Last updated:** [June 10, 2025, 1:22am UTC](https://forum.codecrafters.io/t/timeout-error-for-jv8/11833 "2025-06-10T01:22:18Z")

</div>

I’m stuck on Stage #JV8 with a timeout error. This may be similar to the following posts: JV8 timing out when downloading a file, #jv8: Cannot get it to work when running tests in codecrafters, Execution time out on t…

---

## [Failing to download pieces different than 0 #nd2](https://forum.codecrafters.io/t/failing-to-download-pieces-different-than-0-nd2/11575)

<div class="topic-metadata">

**Author:** [@adecora](https://forum.codecrafters.io/u/adecora)\
**Replies:** 6\
**Last updated:** [June 9, 2025, 6:10pm UTC](https://forum.codecrafters.io/t/failing-to-download-pieces-different-than-0-nd2/11575 "2025-06-09T18:10:18Z")

</div>

This is the traffic I receive when I ask for piece 0: peer: 165.232.35.114:51531 ... recv: \[0 0 0 2 5 224\] # bitfield message receive send: \[0 0 0 2 2 0\] # respond with an interested recv: \[0 0 0 1 1\] # receive an uncho…

---

## [Issue with pipenv and the 'requests' package](https://forum.codecrafters.io/t/issue-with-pipenv-and-the-requests-package/10797)

<div class="topic-metadata">

**Author:** [@zebra-296](https://forum.codecrafters.io/u/zebra-296)\
**Replies:** 2\
**Last updated:** [May 20, 2025, 9:31am UTC](https://forum.codecrafters.io/t/issue-with-pipenv-and-the-requests-package/10797 "2025-05-20T09:31:24Z")

</div>

I used to be able to run the tests fine about one month ago, but coming back to the project, they now fail with the following error: \> codecrafters test Initiating test run... ⚡ This is a turbo test run. https://codecr…

---

## [\#ND2 Connection reset by peer on second pass](https://forum.codecrafters.io/t/nd2-connection-reset-by-peer-on-second-pass/10412)

<div class="topic-metadata">

**Author:** [@ptrhcpang](https://forum.codecrafters.io/u/ptrhcpang)\
**Replies:** 2\
**Last updated:** [May 13, 2025, 2:39am UTC](https://forum.codecrafters.io/t/nd2-connection-reset-by-peer-on-second-pass/10412 "2025-05-13T02:39:23Z")

</div>

I’m stuck on Stage #ND2. This is a problem with my connection being reset by peer and then timing out as the tester tries to download a second piece. A number of other posts have discussed this problem, but it appears t…

---

## [Receiving invalid message ids](https://forum.codecrafters.io/t/receiving-invalid-message-ids/10370)

<div class="topic-metadata">

**Author:** [@EshaanAgg](https://forum.codecrafters.io/u/EshaanAgg)\
**Replies:** 3\
**Last updated:** [May 12, 2025, 7:48am UTC](https://forum.codecrafters.io/t/receiving-invalid-message-ids/10370 "2025-05-12T07:48:30Z")

</div>

I’m stuck on stage #nd2. To implement downloading the mentioned piece, I am basically creating a struct called Peer that handles all the communication with a remote peer. On its instantiation, it performs the handshake,…

---

## [tester::#AH1 failure](https://forum.codecrafters.io/t/tester-ah1-failure/9073)

<div class="topic-metadata">

**Author:** [@karthiksedoc](https://forum.codecrafters.io/u/karthiksedoc)\
**Replies:** 2\
**Last updated:** [April 28, 2025, 12:46pm UTC](https://forum.codecrafters.io/t/tester-ah1-failure/9073 "2025-04-28T12:46:28Z")

</div>

I’m stuck on tester::#AH1. I couldn’t figure out why the exit status is not 0 as it should be, the bash debugging result in correct exit status: remote: \[compile\] Moved ./.codecrafters/run.sh → ./your\_program.sh remote…

---

## [\#FI9 Different Expectation](https://forum.codecrafters.io/t/fi9-different-expectation/9471)

<div class="topic-metadata">

**Author:** [@routineyfans](https://forum.codecrafters.io/u/routineyfans)\
**Replies:** 2\
**Last updated:** [April 27, 2025, 3:41pm UTC](https://forum.codecrafters.io/t/fi9-different-expectation/9471 "2025-04-27T15:41:50Z")

</div>

why tester shows, remote: \[your\_program\] 165.232.41.73:51556 remote: \[your\_program\] 165.232.38.164:51493 remote: \[your\_program\] 165.232.35.114:51476 remote: \[tester::#FI9\] Expected stdout to contain "106.72.196.0:41485"…

---

## [Stuck on receive metadata stage](https://forum.codecrafters.io/t/stuck-on-receive-metadata-stage/9189)

<div class="topic-metadata">

**Author:** [@abhishek-7901](https://forum.codecrafters.io/u/abhishek-7901)\
**Replies:** 8\
**Last updated:** [April 24, 2025, 10:42am UTC](https://forum.codecrafters.io/t/stuck-on-receive-metadata-stage/9189 "2025-04-24T10:42:10Z")

</div>

I’m stuck on Stage #(change to your stage, ex. #ZH1 I have noticed that I am not getting the metadata response, and also noticed that there is an asterisk in what I have sent from my end. Here are my logs: \[tester::#Z…

---

## [\#RB2 SHA1 computation in C](https://forum.codecrafters.io/t/rb2-sha1-computation-in-c/9109)

<div class="topic-metadata">

**Author:** [@ptrhcpang](https://forum.codecrafters.io/u/ptrhcpang)\
**Replies:** 2\
**Last updated:** [April 21, 2025, 7:51am UTC](https://forum.codecrafters.io/t/rb2-sha1-computation-in-c/9109 "2025-04-21T07:51:24Z")

</div>

I’m stuck on Stage #RB2. The program does not seem to compile with Codecrafters because the SHA1 function in openssl/sha.h cannot be found. When compiling locally, it compiles only with the slightly modified bash scr…

[Next page](https://forum.codecrafters.io/tag/challenge-bittorrent/7.md?match_all_tags=true&page=1&tags%5B%5D=challenge%3Abittorrent)
