서버 redis
가 다른 네트워크 네임스페이스에서 실행 중입니다. 클라이언트를 서버에 연결하려고 하는데 redis
계속 기다리지만 응답을 받지 못합니다. 몇 시간이 지났습니다.
클라이언트측 코드:
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();
}
터미널 출력:
secondaryvm@secondaryvm:~/tests$ ./hclient
========================1==================================================
한시간이 지났는데 아직 대기중이라 tcpdump
.이것의 TCP 스트림 출력입니다 tcpdump
. 또한 Redis 서버가 실행 중이고 열려 있는 포트에 ping을 시도했습니다.
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)
여기서 무슨 일이 일어나고 있나요? 그것을 방지하는 방법은 무엇입니까?