redis / redis-py

Redis Python client
MIT License
12.56k stars 2.51k forks source link

pubsub client doesn't receive message with active subscription in Ubuntu Core #956

Closed krnr closed 3 years ago

krnr commented 6 years ago

Hello, Andy. I'm a big fan of Redis and your library, however recently I encountered a strange issue.

I have a client to pubsub subscription in a thread:

r = redis.StrictRedis()
pubsub = r.pubsub(ignore_subscribe_messages=True)
pubsub.subscribe(**{REDIS_CHANNEL_NAME: my_class.my_callback})
thread = pubsub.run_in_thread(sleep_time=1.0)
logger.debug('Start listening for config messages...')

and everything is fine when I run it on my machine. I make a snap package from it, install locally, and again it's fine.

But then I upload and install that package on an IoT device and the hell breaks loose.

127.0.0.1:6379> PUBSUB NUMSUB MACHINE_CONFIG
1) "MACHINE_CONFIG"
2) (integer) 1
127.0.0.1:6379> CLIENT LIST
...
id=8 addr=[::1]:41448 fd=10 name= age=465 idle=464 flags=N db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 om=0 events=r cmd=subscribe
...

$ my-snap.redis-cli monitor | grep "CONFIG"
1518765307.420082 [0 [::1]:41482] "PUBLISH" "MACHINE_CONFIG" "..."

$ sudo journalctl -eu snap.my-snap.part -o cat
...
2018-02-16 10:11:30,380(DEBUG): Start listening for config messages...

I have a client attached, I have a subscription, I have a message in the subscription, I have a process running - everything like on my local machine, except one thing - client doesn't receive that message... If only I restart my service, it begins to consume pubsub as usual.

the only idea I can think of is something related to a socket, but how to check it? I'm naturally positive that this may be specifically Core system issues, but I'd appreciate any help and insights on this, since it may be helpful for devs who will be making products for the IoT devices using Redis.

Thank you.

krnr commented 6 years ago

I tried to use pubsub client without ignore_subscribe_messages=True and it SEEMS to work, however, I'm out of ideas why!

junglegao commented 6 years ago

Have you solved this problem? I have similar issue but the difference is the subscriber will work fine for a while, then it cannot receive any messages, I check the number of subscriber in redid server side by

pubsub numsub CHANNEL_NAME

and get result of 0, meaning at the server side the subscriber is lost, but client side seems in an infinite loop of listening messages.

Dif13 commented 5 years ago

and get result of 0, meaning at the server side the subscriber is lost, but client side seems in an infinite loop of listening messages.

May be you destroy tcp-connection with redis-server. For example conntrack -D -d $IP_redis-server

github-actions[bot] commented 4 years ago

This issue is marked stale. It will be closed in 30 days if it is not updated.

fangdejia commented 3 years ago

Have you solved this problem? I have similar issue but the difference is the subscriber will work fine for a while, then it cannot receive any messages, I check the number of subscriber in redid server side by

pubsub numsub CHANNEL_NAME

and get result of 0, meaning at the server side the subscriber is lost, but client side seems in an infinite loop of listening messages.

I have this problem too!

huangchaosp commented 1 year ago

I encounted this problem too! Does anyone know how to solve it ?

Harsh-Maheshwari commented 1 month ago

Same problem No Solution