Server does not respond to the test Failed to read response: Received: ""

I’m stuck on Stage #AT4

I’ve tried to uncomment and do the first stage, but it failed

Here are my logs:

remote: ------------------------------------------------------------------------
remote: ⚡ This is a turbo test run.
remote: Running tests on your code. Logs should appear shortly...
remote: [compile]   Determining projects to restore...
remote: [compile]   Restored /app/codecrafters-http-server.csproj (in 77 ms).
remote: [compile]   codecrafters-http-server -> /app/bin/Release/net8.0/codecrafters-http-server.dll
remote: [compile] 
remote: [compile] Build succeeded.
remote: [compile]     0 Warning(s)
remote: [compile]     0 Error(s)
remote: [compile] 
remote: [compile] Time Elapsed 00:00:03.82
remote: [compile] Compilation successful.
remote: Debug = true
remote: [tester::#IA4] Running tests for Stage #IA4 (Respond with 200)
remote: [tester::#IA4] Running program
remote: [tester::#IA4] $ ./
remote: [your_program] Logs from your program will appear here!
remote: [tester::#IA4] Connected to localhost port 4221
remote: [tester::#IA4] $ curl -v http://localhost:4221/
remote: [tester::#IA4] > GET / HTTP/1.1
remote: [tester::#IA4] > Host: localhost:4221
remote: [tester::#IA4] > 
remote: [tester::#IA4] Sent bytes: "GET / HTTP/1.1\r\nHost: localhost:4221\r\n\r\n"
remote: [tester::#IA4] Failed to read response: 
remote: [tester::#IA4] Received: "" (no content received)
remote: [tester::#IA4]            ^ error
remote: [tester::#IA4] Error: Expected: HTTP-version, Received: ""
remote: [tester::#IA4] Test failed
remote: [tester::#IA4] Terminating program
remote: [tester::#IA4] Program terminated successfully
remote: View our article on debugging test failures:
   35f3e36..0ffde22  master -> master

And here’s a snippet of my code:

using System.Net;
using System.Net.Sockets;

// You can use print statements as follows for debugging, they'll be visible when running tests.
Console.WriteLine("Logs from your program will appear here!");

// Uncomment this block to pass the first stage
TcpListener server = new TcpListener(IPAddress.Any, 4221);
server.AcceptSocket(); // wait for client

I tried the same challenge in python and it succeeded without error

In IA4 your server should respond with status code 200, the code you posted does not do that.

So, an issue with the starter code?
Do you mean, the code should also return results and not just accept socket?

The stage with the starter code is the stage before that, AT4.

For IA4 you have to start coding yourself, which the stage description states.

Let me update my post, I’m on AT4

This stage is the first change in the code. It asks me to uncomment a part of the code. And that’s what I did. Here is where the tests fail.

Maybe the tests are testing the next stage?

I think I got the issue. As you said, I guess my tests started in the next stage, and I thought I’m still in the first stage

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