Relative Content

Tag Archive for node.jssocketstcpmaster-slave

Master Server Sending Incorrect Commands to Its Replicas

I consider myself a beginner with TCP connections, but I wanted to learn more about it so I started a project called the “Build Your Own Redis Challenge” from codecrafters.io. I am trying to implement the WAIT Redis command. I have set up a master server that connects to its replicas as well as a client. Basically, how the tester works is that it creates replicas that connect to my server, then switches to a client that sends REDIS commands (SET, PING, etc.) to my server and expects responses from the server (“+OKrn”, etc.). For example, when a client sends a “SET” command, it expects a”+OKrn” simple string response back from the server and for that server to propagate that SET command to its replicas. I have noticed that after the tester switches to the client and sends a SET command, the server sends the “+OKrn” response to both the client and to one of its replicas, even though it is only supposed to send the response to just the client. Here is the code for my server: