# Getting Received "" (no content receive) error for 2nd ping in respond to mulitple pings stage redis, java

**URL:** <https://forum.codecrafters.io/t/getting-received-no-content-receive-error-for-2nd-ping-in-respond-to-mulitple-pings-stage-redis-java/1256>\
**Category:** General\
**Tags:** challenge:redis\
**Created:** [August 2, 2024, 8:00pm UTC](https://forum.codecrafters.io/t/getting-received-no-content-receive-error-for-2nd-ping-in-respond-to-mulitple-pings-stage-redis-java/1256 "2024-08-02T20:00:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shradha78](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/shradha78/32/1168_2.png) [@shradha78](https://forum.codecrafters.io/u/shradha78)\
**Post date:** [August 2, 2024, 8:00pm UTC](https://forum.codecrafters.io/t/getting-received-no-content-receive-error-for-2nd-ping-in-respond-to-mulitple-pings-stage-redis-java/1256/1 "2024-08-02T20:00:32Z")

</div>

I have passed this stage earlier, but then after refactoring my code, I am getting this error  
remote: [tester::#ZU2] client-2: $ redis-cli PING  
remote: [tester::#ZU2] client-2: Sent bytes: “\*1\r\n$4\r\nPING\r\n”  
remote: [tester::#ZU2] Received: “” (no content received)  
remote: [tester::#ZU2] ^ error  
remote: [tester::#ZU2] Error: Expected start of a new RESP2 value (either +, -, :, $ or \*)

My code is this:  
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!”);

```
 // Uncomment this block to pass the first stage
    ServerSocket serverSocket = null;
    Socket clientSocket = null;
    int port = 6379;
    try {
        serverSocket = new ServerSocket(port);
        // Since the tester restarts your program quite often, setting SO_REUSEADDR
        // ensures that we don't run into 'Address already in use' errors
        serverSocket.setReuseAddress(true);
        // Wait for connection from client.
        clientSocket = serverSocket.accept();

```

// clientSocket.getOutputStream().write(“+PONG\r\n”.getBytes());  
// System.out.println(“Received PONG from client!”);  
System.out.printf(“Connected with Client : " + clientSocket.getPort() +”\n");  
readMultiplePingsFromSameConnection(clientSocket);  
}  
catch (IOException e) {  
System.out.println("IOException: " + e.getMessage());  
} finally {  
try {  
if (clientSocket != null) {  
clientSocket.close();  
}  
} catch (IOException e) {  
System.out.println("IOException: " + e.getMessage());  
}  
}  
}

```
private static void readMultiplePingsFromSameConnection(Socket clientSocket) throws IOException{
    BufferedReader br = new BufferedReader(
            new InputStreamReader(clientSocket.getInputStream()));
    OutputStream outputStream = clientSocket.getOutputStream();
    String line;
    while ((line = br.readLine()) != null) {
        System.out.printf("send response of ping : " + line + "\n");
        if (line.equalsIgnoreCase("PING")) {
            outputStream.write("+PONG\r\n".getBytes());
            System.out.println("Received PONG from client!");
        }
    }
}

```

I have refactored it by referring to one of the code examples but still getting this error.  
I tried with code example directly, still getting same error, can someone help me with this?
