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()
}