0

a redis server is running in a different network namespace. I'm trying to connect a client to the redis server, it keeps waiting but is not getting response, its been hours.

Client side code:

int main(){

        // ***** Pipeline *****
        auto redis = Redis("tcp://192.168.122.50:6379");
        // Create a pipeline.
//      auto pipe = redis.pipeline(false);
        sleep(5);
        int ep = 1;
    while(true){
cout<<"========================"<<ep++<<"==================================================\n";


        auto pipe = redis.pipeline(false);

        for(int i=1; i<=1000; i++){
            string s = to_string(i);
            if(i%2 == 1){
                pipe.set(s, s);
            }
            else {
                string st = to_string(i-1);
                pipe.get(st);       
            }
        }

        auto pipe_replies = pipe.exec();

        time += duration;    
        mntime = min(duration, mntime);  
        mxtime = max(duration, mxtime); 
        cout<<"RESULTS\n";
        
        for (int i=1; i<=1000; i++) {
           if (i%2 == 1) {
               auto set_result = pipe_replies.get<bool>(i-1);
            cout<<set_result<<"\n";
           } else {
              OptionalString get_result = pipe_replies.get<OptionalString>(i-1);
              if (get_result)
              cout << *get_result << endl;  
             else
              cout << "key does not exist" << endl;
                
          }
        }   

//cout<<"============================================================================\n";
            
        pipe.discard();
    }

Terminal Output:

secondaryvm@secondaryvm:~/tests$ ./hclient
========================1==================================================

It's been an hour, it's still waiting so i analysed it with tcpdump. this is the tcp stream output of tcpdump. I also tried pinging the port at which the redis server was running and it was open.

root@secondaryvm:/home/secondaryvm/tests# nmap -p 6379 192.168.122.50

Starting Nmap 7.60 ( https://nmap.org ) at 2020-12-30 16:26 IST
Nmap scan report for 192.168.122.50
Host is up (0.000050s latency).

PORT     STATE SERVICE
6379/tcp open  redis
MAC Address: FE:2D:4A:25:55:EE (Unknown)

what is happening here? and how to prevent it?

  • Please replicate the problem with `redis-cli` to eliminate your code as a possible cause of the problem (note that we can't help you with your code anyway). You should also provide all _relevant_ information. – Michael Hampton Dec 30 '20 at 16:25
  • But i still wonder why it didn't gave timeout error. – user14610638 Dec 30 '20 at 17:08
  • me any my friend are working on a research project and stucked for long on this error. Can you please look at this: https://unix.stackexchange.com/questions/626528/connection-reset-by-peer-errror-when-delaying-network-response-packets – user14610638 Dec 30 '20 at 17:16
  • @MichaelHampton I encountered this scenario again, this time container is in running state and still the client is stucked for connection. – user14610638 Dec 30 '20 at 18:14
  • As per `redis-cli` standard redis client, It is giving this error: `Could not connect to Redis at 192.168.122.50:6379: Connection timed out` . – user14610638 Dec 30 '20 at 18:16

0 Answers0