# Getting timeout #qv6

**URL:** <https://forum.codecrafters.io/t/getting-timeout-qv6/2710>\
**Category:** Challenges\
**Tags:** challenge:bittorrent\
**Created:** [October 31, 2024, 2:03pm UTC](https://forum.codecrafters.io/t/getting-timeout-qv6/2710 "2024-10-31T14:03:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shide1989](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shide1989/32/2042_2.png) [@shide1989](https://forum.codecrafters.io/u/shide1989)\
**Post date:** [October 31, 2024, 2:03pm UTC](https://forum.codecrafters.io/t/getting-timeout-qv6/2710/1 "2024-10-31T14:03:24Z")

</div>

I’m having the issue too at [bittorrent/stages/qv6](https://app.codecrafters.io/courses/bittorrent/stages/qv6)

My code works just fine when using `cargo run download sample.torrent -o /tmp/test.txt`.  
But using the same parts of code to download pieces from a magnet link, I get the timeout issue when running the `codecrafters test` (or submit) commands.

My Rust code is available at [GitHub - shide1989/shide1989-codecrafters-bittorrent-rust: Build your own BitTorrent challenge ! (in Rust)](https://github.com/shide1989/shide1989-codecrafters-bittorrent-rust/tree/master)

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [October 31, 2024, 2:10pm UTC](https://forum.codecrafters.io/t/getting-timeout-qv6/2710/2 "2024-10-31T14:10:49Z")

</div>

@shide1989 I moved your post to a standalone topic, since it seems to be a separate issue.

I’ll look at your code shortly. In the meantime, could you try adding logs for the download progress to see how far it gets before timing out?

---

<div class="post-metadata">

**Author:** ![shide1989](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shide1989/32/2042_2.png) [@shide1989](https://forum.codecrafters.io/u/shide1989)\
**Post date:** [October 31, 2024, 2:19pm UTC](https://forum.codecrafters.io/t/getting-timeout-qv6/2710/3 "2024-10-31T14:19:48Z")

</div>

Sure, here’s the logs :

```auto
codecrafters-bittorrent-rust on  master [!] ➜ codecrafters submit
Submitting changes (commit: 6248bf8)...

⚡ This is a turbo test run. https://codecrafters.io/turbo

Running tests. Logs should appear shortly...

[compile] Compiling bittorrent-starter-rust v0.1.0 (/app)
[compile] Finished release [optimized] target(s) in 19.05s
[compile] Compilation successful.

[tester::#QV6] Running tests for Stage #QV6 (Magnet Links - Download a piece)
[tester::#QV6] Running ./your_bittorrent.sh magnet_download_piece -o /tmp/torrents1394643788/piece-0 "magnet:?xt=urn:btih:3f994a835e090238873498636b98a3e78d1c34ca&dn=magnet2.gif&tr=http%3A%2F%2Fbittorrent-test-tracker.codecrafters.io%2Fannounce" 0
[your_program] Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce
[your_program] Name: Some("magnet2.gif")
[your_program] Peer ID: 2d524e302e302e302d4f371471616c6c5bb2078d
[your_program] Peer extensions: [16]
[your_program] Peer Metadata Extension ID: 1
[your_program] Peer Metadata Size: 91
[your_program] MessageID [1]
[your_program] Received payload "d8:msg_typei1e5:piecei0e10:total_sizei91eed6:lengthi79752e4:name11:magnet2.gif12:piece lengthi262144e6:pieces20:×\u{8a}\u{7f}UÝØ\u{9f}ïG{Ä\u{9d}\u{93}\u{8b}ÇäÙ@\u{94}ñe"
[your_program] Received message ID 1
[your_program] Length: 79752
[your_program] Info Hash: 3f994a835e090238873498636b98a3e78d1c34ca
[your_program] Piece Length: 262144
[your_program] d78a7f55ddd89fef477bc49d938bc7e4d94094f1
[your_program] - Downloading piece: piece_index: 0, piece_len: 262144
[your_program] - Downloading block: piece_index: 0, begin: 0, length: 16384
[your_program] - Downloading block: piece_index: 0, begin: 49152, length: 16384
[your_program] - Downloading block: piece_index: 0, begin: 65536, length: 16384
[your_program] - Downloading block: piece_index: 0, begin: 16384, length: 16384
[your_program] - Downloading block: piece_index: 0, begin: 32768, length: 16384
[tester::#QV6] timed out, test exceeded 10 seconds
[tester::#QV6] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)

View our article on debugging test failures: https://codecrafters.io/debug

```

I also tried to limit the simultaneous tcpStream writes sent to 5, to see if I was getting some kind of blocked, but it didn’t change anything

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 3, 2024, 1:00am UTC](https://forum.codecrafters.io/t/getting-timeout-qv6/2710/5 "2024-11-03T01:00:42Z")

</div>

@shide1989 I tried running your code, but it hangs both with `codecrafters test` and when run locally.

Could you try running this command locally to see if it hangs or works for you as well?

```auto
./your_bittorrent.sh magnet_download_piece -o /tmp/torrents1485664656/piece-1 "magnet:?xt=urn:btih:ad42ce8109f54c99613ce38f9b4d87e70f24a165&dn=magnet1.gif&tr=http%3A%2F%2Fbittorrent-test-tracker.codecrafters.io%2Fannounce" 1

```

---

<div class="post-metadata">

**Author:** ![shide1989](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shide1989/32/2042_2.png) [@shide1989](https://forum.codecrafters.io/u/shide1989)\
**Post date:** [November 5, 2024, 3:38pm UTC](https://forum.codecrafters.io/t/getting-timeout-qv6/2710/7 "2024-11-05T15:38:18Z")

</div>

Yeah it hangs, its been like this for this stage

---

<div class="post-metadata">

**Author:** ![shide1989](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shide1989/32/2042_2.png) [@shide1989](https://forum.codecrafters.io/u/shide1989)\
**Post date:** [November 6, 2024, 9:37pm UTC](https://forum.codecrafters.io/t/getting-timeout-qv6/2710/9 "2024-11-06T21:37:44Z")

</div>

Somewhere in the process I was missing a “send interest” message, due to the new code for the magnet link.

After adding it, it worked just fine.

Thanks for your help !

(now I just have to get a free Membership week to be able to submit it lol)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [November 12, 2024, 12:44am UTC](https://forum.codecrafters.io/t/getting-timeout-qv6/2710/11 "2024-11-12T00:44:56Z")

</div>

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