Null status reply (original) (raw)

This time I'm running a redis-plus-plus client on a different machine than server, However i think i've not installed redis-plus-plus correctly, i tried multiple times and download multiple versions of hiredis to make this work, but every time i compile the client with below command, i get this result as shown below:

 root@user-HP-Pavilion-Notebook:/home/user/tests/redisclient# g++ -std=c++11 -o hclient hclient.cpp -lredis++ -lhiredis
/usr/bin/ld: warning: libhiredis.so.1.0.1-dev, needed by /usr/local/lib/libredis++.so, may conflict with libhiredis.so.0.14

and while running the client, I get this error:

 terminate called after throwing an instance of 'sw::redis::ProtoError'
  what():  A null status reply
Aborted (core dumped)

As my client is using OptionalString so I tried compiling it with -stdc++=17:

root@user-HP-Pavilion-Notebook:/home/user/tests/redisclient# g++ -std=c++17 -o hclient hclient.cpp -lredis++ -lhiredis
/usr/bin/ld: warning: libhiredis.so.1.0.1-dev, needed by /usr/local/lib/libredis++.so, may conflict with libhiredis.so.0.14
/usr/bin/ld: /tmp/ccug3Swh.o: in function `sw::redis::QueuedRedis<sw::redis::PipelineImpl>::set(std::basic_string_view<char, std::char_traits<char> > const&, std::basic_string_view<char, std::char_traits<char> > const&, std::chrono::duration<long, std::ratio<1l, 1000l> > const&, sw::redis::UpdateType)':
hclient.cpp:(.text._ZN2sw5redis11QueuedRedisINS0_12PipelineImplEE3setERKSt17basic_string_viewIcSt11char_traitsIcEES9_RKNSt6chrono8durationIlSt5ratioILl1ELl1000EEEENS0_10UpdateTypeE[_ZN2sw5redis11QueuedRedisINS0_12PipelineImplEE3setERKSt17basic_string_viewIcSt11char_traitsIcEES9_RKNSt6chrono8durationIlSt5ratioILl1ELl1000EEEENS0_10UpdateTypeE]+0x77): undefined reference to `sw::redis::cmd::set(sw::redis::Connection&, std::basic_string_view<char, std::char_traits<char> > const&, std::basic_string_view<char, std::char_traits<char> > const&, long long, sw::redis::UpdateType)'
collect2: error: ld returned 1 exit status

Redis-client:

#include <sw/redis++/redis++.h>
#include <bits/stdc++.h>
#include <unistd.h>

#define ll long long 
using namespace std;
using namespace sw::redis;

int main(){

        // ***** Pipeline *****
        auto redis = Redis("tcp://192.168.122.36:6379");
        // Create a pipeline.
//	    auto pipe = redis.pipeline(false);
        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();
        
        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;
          		
          }
        }	
        pipe.discard();
    }

return 0;
}