Unable to spawn 'Slave' process. Stage 6 (sending handshake 2/3) of Redis Replication extension

I’m stuck on Stage #EH4

Unable to spawn a slave process on the specified port on localhost

I’ve tried … flushing streams and ensuring all connections and streams are closed.

Here are my logs:

[tester::#HC6] Running tests for Stage #HC6 (Replication - The INFO command on a replica)
[tester::#HC6] Master is running on port 6379
[tester::#HC6] $ ./spawn_redis_server.sh --port 6380 --replicaof "localhost 6379"
[your_program] Logs from your program will appear here!
[your_program] ping response = 43
[your_program] repl conf response = 80
[your_program] repl conf response = 79
[tester::#HC6] dial tcp 127.0.0.1:6380: connect: connection refused
[tester::#HC6] Test failed
[tester::#HC6] Terminating program

And here’s a snippet of my code:

private def slaveConnectMaster(host: String, port: Int): Unit = {
    val masterSocket = new Socket(host, port)
    val outputStream: OutputStream = masterSocket.getOutputStream
    val writer = new PrintWriter(outputStream, true)
    val inputStream = masterSocket.getInputStream
    val reader = new InputStreamReader(inputStream)

    writer.print("*1\r\n$4\r\nPING\r\n")
    writer.flush()
    val pingResponse = reader.read()
    println(s"ping response = ${pingResponse}")
    writer.print("*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n")
    writer.flush()
    val replConfResponse = reader.read()
    println(s"repl conf response = ${replConfResponse}")
    writer.print("*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n")
    writer.flush()
    val replConfResponse2 = reader.read()
    println(s"repl conf response = ${replConfResponse2}")

    writer.close()
    reader.close()
    outputStream.close()
    inputStream.close()
    masterSocket.close()
  }

There was a mistake in my code. This issue is resolved now.

@soodankit91 thanks for letting us know! What was the error btw? Would be helpful for others who might stumble upon this in the future.

@rohitpaulk
I was trying to connect to the master process before spinning my worker process :slight_smile:

1 Like

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