In the Heroku docs, they have listed some example code for constructing a JedisPool instance from Java.
https://devcenter.heroku.com/articles/heroku-redis#connecting-in-java
public static JedisPool getPool() { URI redisURI = new URI(System.getenv("REDIS_URL")); JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxTotal(10); poolConfig.setMaxIdle(5); poolConfig.setMinIdle(1); poolConfig.setTestOnBorrow(true); poolConfig.setTestOnReturn(true); poolConfig.setTestWhileIdle(true); JedisPool pool = new JedisPool(poolConfig, redisURI); return pool;}
The example is extremely straight forward. Get a URI from the environment variable, set some settings, and the pool should work. I am trying this from clojure, which shouldn't be an issue but it might be useful context, and my code for constructing a pool looks like this.
;; ----------------------------------------------------------------------------(defn create-client-pool"Creates a connection pool for connecting to redis." [config] (JedisPool. (doto (JedisPoolConfig.) (.setMaxTotal 10) (.setMaxIdle 5) (.setMinIdle 1) (.setTestOnBorrow true) (.setTestOnReturn true) (.setTestWhileIdle true)) (URI. (config/redis-url config))))
Where config/redis-url
pulls the REDIS_URL
environment variable. (I have tested that part at least with logging). When I try to get a connection from the pool I get this error.
2020-10-24T18:50:56.359137+00:00 app[web.1]: {:type redis.clients.jedis.exceptions.JedisConnectionException2020-10-24T18:50:56.359137+00:00 app[web.1]: :message "Could not get a resource from the pool"2020-10-24T18:50:56.359137+00:00 app[web.1]: :at [redis.clients.jedis.util.Pool getResource "Pool.java" 59]}2020-10-24T18:50:56.359138+00:00 app[web.1]: {:type redis.clients.jedis.exceptions.JedisDataException2020-10-24T18:50:56.359138+00:00 app[web.1]: :message "ERR wrong number of arguments for 'auth' command"2020-10-24T18:50:56.359139+00:00 app[web.1]: :at [redis.clients.jedis.Protocol processError "Protocol.java" 132]}]
Which at this point I have no clue how to tackle, since what I am doing should exactly match the semantics of the example code from Heroku. Perhaps it was written with an older version of Jedis in mind than 3.3? It feels like other people should be running into this, but I can't find examples.
EDIT: It might be related to this https://devcenter.heroku.com/changelog-items/1932 but even knowing they changed a parameter doesn't give me an idea of what to change.