Connection Reset Error

Here is the function that handles the connection -

func handleConnection(conn net.Conn) {
	defer conn.Close()

	var messageLen, correlationID uint32

	if err := binary.Read(conn, binary.BigEndian, &messageLen); err != nil {
		fmt.Println("Error reading message length:", err)
		return
	}

	// Parse fields
	var apiKey, apiVersion int16
	if err := binary.Read(conn, binary.BigEndian, &apiKey); err != nil {
		fmt.Println("Error reading API key:", err)
		return
	}
	if err := binary.Read(conn, binary.BigEndian, &apiVersion); err != nil {
		fmt.Println("Error reading API version:", err)
		return
	}
	if err := binary.Read(conn, binary.BigEndian, &correlationID); err != nil {
		fmt.Println("Error reading correlation ID:", err)
		return
	}

	fmt.Printf("API Key: %d\n", apiKey)
	fmt.Printf("API Version: %d\n", apiVersion)
	fmt.Printf("Correlation ID: %d\n", correlationID)

	// Check API version
	if apiVersion < 0 || apiVersion > 4 {
		fmt.Println("In err response")

		sendErrorResponse(conn, correlationID, 35) // UNSUPPORTED_VERSION
		os.Exit(1)
	}

	sendSuccessResponse(conn, correlationID)
}

I’m stuck on Stage #NC5(change to your stage, ex. #JM3),
I am getting the error when the API Version is outside the whitelisted range i.e. 0 - 4

Here are my logs:

remote: [tester::#NC5] error reading from connection: read tcp [::1]:51552->[::1]:9092: read: connection reset by peer
remote: [tester::#NC5] Test failed

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