-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
"IndexError: string index out of range" on get_message from PubSub #3444
Comments
Hi @jmspereira, can you please share more details about how you are initialising your client and using the pubsub? Some small code example would be great! |
Hey @petyaslavova, thank you for the response! This minimal example should illustrate how I am initializing the connection with redis and using the pubsub: import socket
from redis import Sentinel
from redis.backoff import ExponentialBackoff
from redis.retry import Retry
from redis.exceptions import ConnectionError as RedisConnectionError
from redis.exceptions import TimeoutError as RedisTimeoutError
def main():
sentinel = Sentinel(
[('localhost', 26379), ('localhost', 26380), ('localhost', 26381)],
min_other_sentinels=0,
encoding="utf-8",
decode_responses=True,
socket_keepalive=True,
socket_timeout=30,
socket_connect_timeout=30,
health_check_interval=5,
retry_on_error=(RedisConnectionError, RedisTimeoutError, socket.timeout),
retry=Retry(ExponentialBackoff(10, 0.5), 5),
db=0,
)
connection = sentinel.master_for("mymaster")
connection.config_set("notify-keyspace-events", "KEA")
pub_sub = connection.pubsub()
while True:
event = pub_sub.get_message(timeout=1, ignore_subscribe_messages=True)
if event:
print(event)
else:
print("No event")
if __name__ == '__main__':
main() Additional notes:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version: What redis-py and what redis version is the issue happening on?
redis-py 5.2.0 with redis 7.2.4
Platform: What platform / version?
Python 3.10.12 on Ubuntu 22.04
Description:
Hey everyone,
I have an application that uses Redis in a production environment, but the service crashed during a call to the get_message method from PubSub with the following error (unfortunately I am not able to reproduce the error after several attempts):
Do you have any ideas on how this is possible?
Best regards,
Jorge
The text was updated successfully, but these errors were encountered: