billcobbler / casbin-redis-watcher

Redis watcher for Casbin https://github.com/casbin/casbin
Apache License 2.0
19 stars 23 forks source link

Is there a mechanism to restore the redis connection? #21

Closed asura-10 closed 3 years ago

asura-10 commented 3 years ago

When the connection timed out and was disconnected by proxy of redis cluster, it was not found or restored.

Is there a plan to deal with this problem?

billcobbler commented 3 years ago

It should already attempt to reconnect every 2 seconds as driven by this loop here.

asura-10 commented 3 years ago

I found this piece of code. But I test it in my localhost, When I restart the instance of redis , it will be reconnected, When I add iptables policy below

iptables -A OUTPUT -p tcp -m tcp --tcp-flags PSH PSH --sport 6379 -j DROP

My code showed nothing, doesn't show retry connect information.

asura-10 commented 3 years ago

one more question, why the reconnection code only exists in NewWatcher? not in NewPublishWatcher?

uran0sH commented 3 years ago

I found this piece of code. But I test it in my localhost, When I restart the instance of redis , it will be reconnected, When I add iptables policy below

iptables -A OUTPUT -p tcp -m tcp --tcp-flags PSH PSH --sport 6379 -j DROP

My code showed nothing, doesn't show retry connect information.

It doesn't seem that it allows the packet to be sent out

asura-10 commented 3 years ago

I found this piece of code. But I test it in my localhost, When I restart the instance of redis , it will be reconnected, When I add iptables policy below iptables -A OUTPUT -p tcp -m tcp --tcp-flags PSH PSH --sport 6379 -j DROP My code showed nothing, doesn't show retry connect information.

It doesn't seem that it allows the packet to be sent out

yes, I drop the network packages, it should be try reconnecting after a period of time, but it doesn't.

hsluoyz commented 3 years ago

@asura-10 can you debug the code and set a breakpoint inside: https://github.com/billcobbler/casbin-redis-watcher/blob/master/watcher.go#L90 , see whether it is get called?

asura-10 commented 3 years ago

@asura-10 can you debug the code and set a breakpoint inside: https://github.com/billcobbler/casbin-redis-watcher/blob/master/watcher.go#L90 , see whether it is get called?

Maybe it need a long period of time , about 20 mins, so I close this issue now, thanks