来自Redis客户端Jedis的管道异常断开

时间:2014-03-06 11:39:49

标签: scala playframework redis akka jedis

我们有一个来自Play框架应用程序的redis客户端调用。这个Redis调用是使用Akka Schedular从一个Actor制作的。此调度程序每60秒运行一次,这使得redis调用与其他JDBC调用一起。调度程序运行几分钟后,我们开始看到跟随日志文件,应用程序停止响应任何Redis客户端调用。这是我第一次遇到Redis所以任何指针,帮助都很受欢迎。

redis.host = localhost

redis.port = 6379

redis.timeout = 10

redis.pool.maxActive =110

redis.pool.maxIdle = 50

redis.pool.maxWait = 3000

redis.pool.testOnBorrow = true

redis.pool.testOnReturn = true

redis.pool.testWhileIdle = true

redis.pool.timeBetweenEvictionRunsMillis = 60000

redis.pool.numTestsPerEvictionRun = 10

Exception details:

redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Broken pipe
    at redis.clients.jedis.Connection.flush(Connection.java:69) ~[redis.clients.jedis-2.3.0.jar:na]
    at redis.clients.jedis.JedisPubSub.subscribe(JedisPubSub.java:58) ~[redis.clients.jedis-2.3.0.jar:na]
............    
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) [com.typesafe.akka.akka-actor_2.10-2.2.0.jar:2.2.0]
    at akka.actor.ActorCell.invoke(ActorCell.scala:456) [com.typesafe.akka.akka-actor_2.10-2.2.0.jar:2.2.0]
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) [com.typesafe.akka.akka-actor_2.10-2.2.0.jar:2.2.0]
    at akka.dispatch.Mailbox.run(Mailbox.scala:219) [com.typesafe.akka.akka-actor_2.10-2.2.0.jar:2.2.0]
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386) [com.typesafe.akka.akka-actor_2.10-2.2.0.jar:2.2.0]
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [org.scala-lang.scala-library-2.10.3.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [org.scala-lang.scala-library-2.10.3.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [org.scala-lang.scala-library-2.10.3.jar:na]
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [org.scala-lang.scala-library-2.10.3.jar:na]
Caused by: java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.7.0_51]
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113) ~[na:1.7.0_51]
    at java.net.SocketOutputStream.write(SocketOutputStream.java:159) ~[na:1.7.0_51]
    at redis.clients.util.RedisOutputStream.flushBuffer(RedisOutputStream.java:31) ~[redis.clients.jedis-2.3.0.jar:na]
    at redis.clients.util.RedisOutputStream.flush(RedisOutputStream.java:223) ~[redis.clients.jedis-2.3.0.jar:na]
    at redis.clients.jedis.Connection.flush(Connection.java:67) ~[redis.clients.jedis-2.3.0.jar:na]
    ... 15 common frames omitted

2 个答案:

答案 0 :(得分:0)

问题在于超时,以及您用于订阅的客户端超时/获得DC编辑。

答案 1 :(得分:0)

我最近遇到了与Redis类似的问题,问题是,我订阅后没有返回Jedis资源,因此连接泄漏,并且应用程序在几次连接后没有响应。因此,不要忘记在执行任何操作后返回jedis资源:

Jedis j = play.Play.application().plugin(RedisPlugin.class).jedisPool().getResource();
j.subscribe(listener, redisChannel);
play.Play.application().plugin(RedisPlugin.class).jedisPool().returnResource(j);