# Submission issues in blocking retrieval #ec3

**URL:** <https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [August 20, 2025, 10:49am UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145 "2025-08-20T10:49:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulLocksley](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/paullocksley/32/16069_2.png) [@PaulLocksley](https://forum.codecrafters.io/u/PaulLocksley)\
**Post date:** [August 20, 2025, 10:49am UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/1 "2025-08-20T10:49:13Z")

</div>

I’m stuck on Stage Blocking retrieval #ec3.

Hey all, Having an issue on submission here where the redis-cli in the runner isn’t reporting any output.

Locally my redis-cli works with the same commands, it’s semi inconsistant (sometimes it fails on an earlier stage). Submitted over several days to try and clear any build cache on CodeCrafters side.

Any ideas would be appreciated 🙂

Here are my logs:

```auto
remote: [tester::#EC3] Running tests for Stage #EC3 (Lists - Blocking retrieval) remote: [tester::#EC3] $ ./your_program.sh remote: [tester::#EC3] [client-1] Connected (port 49124 -> port 6379) 
remote: [tester::#EC3] [client-2] Connected (port 49136 -> port 6379) 
remote: [tester::#EC3] [client-3] Connected (port 49150 -> port 6379) 
remote: [tester::#EC3] [client-2] $ redis-cli BLPOP blueberry 0 remote: [tester::#EC3] [client-2] Sent bytes: "*3\r\n$5\r\nBLPOP\r\n$9\r\nblueberry\r\n$1\r\n0\r\n" 
remote: [tester::#EC3] [client-3] $ redis-cli BLPOP blueberry 0 
remote: [tester::#EC3] [client-3] Sent bytes: "*3\r\n$5\r\nBLPOP\r\n$9\r\nblueberry\r\n$1\r\n0\r\n" 
remote: [tester::#EC3] [client-1] $ redis-cli RPUSH blueberry mango 
remote: [tester::#EC3] [client-1] Sent bytes: "*3\r\n$5\r\nRPUSH\r\n$9\r\nblueberry\r\n$5\r\nmango\r\n"
remote: [your_program] Sending output to client: :1 
remote: [your_program] 
remote: [your_program] stream status: canwrite True 
remote: [your_program] Sending output to client: *2 
remote: [your_program] $9 
remote: [your_program] blueberry 
remote: [your_program] $5 
remote: [your_program] mango 
remote: [your_program] 
remote: [your_program] stream status: canwrite True 
remote: [tester::#EC3] [client-1] Received bytes: ":1\r\n" 
remote: [tester::#EC3] [client-1] Received RESP integer: 1 
remote: [tester::#EC3] [client-1] ✔︎ Received 1 
remote: [tester::#EC3] [client-2] Expecting response of BLPOP command 
remote: [tester::#EC3] Received: "" (no content received) 
remote: [tester::#EC3] ^ error remote: [tester::#EC3] Error: Expected start of a new RESP2 value (either +, -, :, $ or *) 
remote: [tester::#EC3] Test failed remote: [tester::#EC3] Terminating program remote: [tester::#EC3] Program terminated successfully remote:

```

Same code failing eleswhere (but less log statements sorry)

```auto
remote: [tester::#EC3] [client-1] Connected (port 36236 -> port 6379) remote: [tester::#EC3] [client-2] Connected (port 36238 -> port 6379) remote: [tester::#EC3] [client-3] Connected (port 36240 -> port 6379) remote: [tester::#EC3] [client-2] $ redis-cli BLPOP strawberry 0 remote: [tester::#EC3] [client-2] Sent bytes: "*3\r\n$5\r\nBLPOP\r\n$10\r\nstrawberry\r\n$1\r\n0\r\n" remote: [tester::#EC3] [client-3] $ redis-cli BLPOP strawberry 0
remote: [tester::#EC3] [client-3] Sent bytes: "*3\r\n$5\r\nBLPOP\r\n$10\r\nstrawberry\r\n$1\r\n0\r\n" remote: [tester::#EC3] [client-1] $ redis-cli RPUSH strawberry grape remote: [tester::#EC3] [client-1] Sent bytes: "*3\r\n$5\r\nRPUSH\r\n$10\r\nstrawberry\r\n$5\r\ngrape\r\n" remote: [tester::#EC3] [client-1] Received bytes: ":1\r\n"
remote: [tester::#EC3] [client-1] Received RESP integer: 1
remote: [tester::#EC3] [client-1] ✔︎ Received 1
remote: [tester::#EC3] [client-2] Expecting response of BLPOP command remote: [tester::#EC3] [client-2] Received bytes: "*2\r\n$10\r\nstrawberry\r\n$5\r\ngrape\r\n" remote: [tester::#EC3] [client-2] Received RESP array: ["strawberry", "grape"] remote: [tester::#EC3] [client-2] ✔︎ Received ["strawberry", "grape"] remote: [tester::#EC3] [client-3] Expecting no response
remote: [tester::#EC3] [client-3] ✔︎ No response received yet
remote: [tester::#EC3] Test passed.
remote: [tester::#EC3] Terminating program
remote: [tester::#EC3] Program terminated successfully
remote:
remote: [tester::#JP1] Running tests for Stage #JP1 (Lists - Remove multiple elements) remote: [tester::#JP1] $ ./your_program.sh
remote: [tester::#JP1] [client] $ redis-cli RPUSH banana strawberry pineapple blueberry mango grape banana pear remote: [tester::#JP1] [client] Sent bytes: "*9\r\n$5\r\nRPUSH\r\n$6\r\nbanana\r\n$10\r\nstrawberry\r\n$9\r\npineapple\r\n$9\r\nblueberry\r\n$5\r\nmango\r\n$5\r\ngrape\r\n$6\r\nbanana\r\n$4\r\npear\r\n" remote: [tester::#JP1] [client] Received bytes: ":7\r\n"
remote: [tester::#JP1] [client] Received RESP integer: 7
remote: [tester::#JP1] [client] ✔︎ Received 7
remote: [tester::#JP1] [client] > LPOP banana 2
remote: [tester::#JP1] [client] Sent bytes: "*3\r\n$4\r\nLPOP\r\n$6\r\nbanana\r\n$1\r\n2\r\n" remote: [tester::#JP1] Received: "" (no content received) remote: [tester::#JP1] ^ error remote: [tester::#JP1] Error: Expected start of a new RESP2 value (either +, -, :, $ or *) remote: [tester::#JP1] Test failed remote: [tester::#JP1] Terminating program remote: [tester::#JP1] Program terminated successfully   

```

And here’s a snippet of my code:

```python
            Console.WriteLine($"Sending output to client: {output_string} \n stream status: canwrite {stream.CanWrite}");
            stream.Write(Encoding.UTF8.GetBytes(output_string.ToString()));
            await stream.FlushAsync();
            stream.Close();

```

---

<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:** [August 20, 2025, 10:50am UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/4 "2025-08-20T10:50:15Z")

</div>

Hey @PaulLocksley, could you [upload your code to GitHub](https://docs.codecrafters.io/features/publish-to-github) and share the link? It will be much easier to debug if I can run it directly.

---

<div class="post-metadata">

**Author:** ![PaulLocksley](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/paullocksley/32/16069_2.png) [@PaulLocksley](https://forum.codecrafters.io/u/PaulLocksley)\
**Post date:** [August 20, 2025, 10:54am UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/5 "2025-08-20T10:54:21Z")

</div>

Sure, [GitHub - PaulLocksley/-codecrafters-redis-csharp: Not worth reading.](https://github.com/PaulLocksley/-codecrafters-redis-csharp)

---

<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:** [August 24, 2025, 2:21pm UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/6 "2025-08-24T14:21:17Z")

</div>

Hey @PaulLocksley, sorry for the delayed response!

There might be a few issues at play. The first one I noticed is that `handleConnection` no longer handles multiple commands from the same connection.

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/9/9/99161c106ea1cefacd30a680ea9aa07ade039079.png)

**Suggestions** :

1. Use [our CLI](https://docs.codecrafters.io/cli/installation) to test against previous stages by running:

```auto
codecrafters test --previous

```

1. Focus on fixing the early stages first, as later stages depend on them.

Once you’ve got this sorted out, we can keep going from there.

---

<div class="post-metadata">

**Author:** ![PaulLocksley](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/paullocksley/32/16069_2.png) [@PaulLocksley](https://forum.codecrafters.io/u/PaulLocksley)\
**Post date:** [August 25, 2025, 6:55am UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/8 "2025-08-25T06:55:04Z")

</div>

Thanks @andy1li , yeah I removed the loop when I was testing if not exiting the stream properly was causing the issue.  
Added it back to pass previous tests 🙂

Back to failing only on #EC3 🙂

---

<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:** [August 25, 2025, 3:18pm UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/10 "2025-08-25T15:18:49Z")

</div>

Hmm, looks like the pop result was sent to an unexpected client (client-3):

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/3/1/314a7ba5447d44b22aaed8539245de5143f455a2.jpeg)

Although client-2 initiated the connection before client-3, the logs show client-3 as the first to connect.

~~I’m opening [a PR](https://github.com/codecrafters-io/redis-tester/pull/217) to enforce the correct order and will update here once the fix is merged.~~

---

<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:** [August 26, 2025, 10:08pm UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/11 "2025-08-26T22:08:43Z")

</div>

@PaulLocksley The root cause is the use of `AcceptTcpClientAsync`. A simple fix is to switch to the synchronous version:

```auto
    private static void Main(string[] args)
    {
        var cache = new RedisCache();
        var server = new TcpListener(IPAddress.Any, 6379);
        server.Start();

        try
        {
            while (true)
            {
                var client = server.AcceptTcpClient();
                Task.Run(() => handleConnection(client, cache));
            }
        }
        finally
        {
            server.Stop();
        }
    }

```

BTW, it’s generally not ideal to keep everything in Main. You might want to move most of the logic into separate methods or classes for better clarity and maintainability.

---

<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:** [September 1, 2025, 8:18pm UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/13 "2025-09-01T20:18:24Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<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:** [September 6, 2025, 8:18pm UTC](https://forum.codecrafters.io/t/submission-issues-in-blocking-retrieval-ec3/15145/14 "2025-09-06T20:18:44Z")

</div>

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