2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-23 04:28:01 +00:00

Attempt to fix PubSub disconnection issues.

This commit is contained in:
Tux 2015-12-06 12:12:55 -05:00
parent 84029fa856
commit 565de9b4c0

View File

@ -96,7 +96,7 @@ public final class RedisBungee extends Plugin {
if (lagged ? time >= stamp + 30 : time <= stamp + 30) if (lagged ? time >= stamp + 30 : time <= stamp + 30)
servers.add(entry.getKey()); servers.add(entry.getKey());
else if (nag && nagTime <= 0) { else if (nag && nagTime <= 0) {
getLogger().severe(entry.getKey() + " is " + (System.currentTimeMillis() - stamp) + "ms behind! (Time not synchronized or server down?)"); getLogger().severe(entry.getKey() + " is " + (time - stamp) + " seconds behind! (Time not synchronized or server down?)");
} }
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
} }
@ -505,10 +505,22 @@ public final class RedisBungee extends Plugin {
@Override @Override
public void run() { public void run() {
boolean broken = false;
try (Jedis rsc = pool.getResource()) { try (Jedis rsc = pool.getResource()) {
jpsh = new JedisPubSubHandler(); try {
rsc.subscribe(jpsh, "redisbungee-" + configuration.getServerId(), "redisbungee-allservers", "redisbungee-data"); jpsh = new JedisPubSubHandler();
} catch (JedisException | ClassCastException ignored) { rsc.subscribe(jpsh, "redisbungee-" + configuration.getServerId(), "redisbungee-allservers", "redisbungee-data");
} catch (Exception e) {
// FIXME: Extremely ugly hack
// Attempt to unsubscribe this instance and try again.
getLogger().log(Level.INFO, "PubSub error, attempting to recover.", e);
jpsh.unsubscribe();
broken = true;
}
}
if (broken) {
run();
} }
} }