Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null status reply #140

Closed
ashwani29 opened this issue Jan 4, 2021 · 2 comments
Closed

Null status reply #140

ashwani29 opened this issue Jan 4, 2021 · 2 comments

Comments

@ashwani29
Copy link

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;
}

@sewenew
Copy link
Owner

sewenew commented Jan 5, 2021

If the code works in other environment, you'd better uninstall hiredis, and redis-plus-plus completely first, and then reinstall these libraries, and try again.

It seems that libhiredis.so.1.0.1-dev is installed with apt-get or yum, and libhiredis.so.0.14 is manually installed. Another option is to manually install hiredis at a non-default location, and depend on this version.

Regards

@ashwani29
Copy link
Author

Got it working, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants