Expected: HTTP-version, Received: ""

I’m stuck on Stage #IA4.

Here are my logs:

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 (try setting 'debug: true' in your codecrafters.yml to see more details)

And here’s a snippet of my code:

public static void main(String[] args) {
        // You can use print statements as follows for debugging, they'll be visible
        // when running tests.
        System.out.println("Logs from your program will appear here!");
        ServerSocket serverSocket = null;
        Socket clientSocket = null;
        try {
            serverSocket = new ServerSocket(4221);
            // Since the tester restarts your program quite often, setting
            // SO_REUSEADDR ensures that we don't run into 'Address already in use'
            serverSocket.setReuseAddress(true);
            clientSocket = serverSocket.accept(); // Wait for connection from client.
            System.out.println("accepted new connection");
            String response = "HTTP/1.1 200 OK\r\n\r\n";
            clientSocket.getOutputStream().write(response.getBytes());
        } catch (IOException e) {
            System.out.println("IOException: " + e.getMessage());
        }
    }```
1 Like

@pvrahul271199 looks like you managed to figure this out. Do you happen to remember what the issue was? Would be helpful for others who stumble upon this post :slightly_smiling_face: