1.14.4 Redis issue (Connection broke after some time on external serverv)

Discussion in 'Spigot Plugin Development' started by JoeyPlayzTV, Mar 8, 2020.

  1. I have a problem. If i use redis pub/sub on a externel server the client that subscribe disconnect after some time
    randomly. i use the folowing redis manager. and jedis newest version


    Code (Java):
    public class RedisManager {
     
        private final JedisPool mainpool;
        private Thread reciver;
     
        public RedisManager(String host, String auth) {
            this.mainpool = new JedisPool(new JedisPoolConfig(), host, 6379, 0, auth);
        }
     
        /**
         * Gibt die Systemresourcen frei!
         */

        public void close() {
            if(mainpool != null) {
                mainpool.close();
            }
            if(reciver != null) {
                reciver.interrupt();
            }
        }
     
        /**
         * Gibt eine neue Verbindung zurück.
         * @return
         */

        public Jedis getPooledConnection() {
            Jedis tmp = mainpool.getResource();
            return tmp;
        }
     
        /**
         * Weist dem Object einen Empfänger zu.
         * @param bubsub
         */

        public void setReciver(JedisPubSub pubsub, String channel) {
            if(reciver == null) {
                reciver = new Thread(()->{
                    Jedis rec = getPooledConnection();
                    rec.subscribe(pubsub, channel);
                });
                reciver.start();
                System.out.println("[System] Reciver is now running!");
            }else {
                System.out.println("[System] This object already has an Reciver!");
            }
        }
    }
    Has someone a same issue or know, what i make wrong?
     
  2. Had this issue too a bit ago, we have since switched to https://lettuce.io/ instead of Jedis and never had issues with their reconnect and recovery options.
     
  3. Yea the api is verry wierd i like the jedis because its extrem understandable. and the other one is to wierd with the futures and the wierd "<>>>" suff