java - Redis throw exceptioon about "Read time out" -


i'm new redis, start server tutorial. , work. use write code using java connect redis, it's ok, this:

      jedis jedis = new jedis("localhost");       system.out.println("connection server sucessfully");       //store data in redis list       jedis.lpush("tutorial-list", "redis");       jedis.lpush("tutorial-list", "mongodb");       jedis.lpush("tutorial-list", "mysql"); 

but, when use multithread push redis, throw exception "read time out":

exception in thread "main" java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ org.eclipse.jdt.internal.jarinjarloader.jarrsrcloader.main(jarrsrcloader.java:58) caused by: redis.clients.jedis.exceptions.jedisconnectionexception: java.net.sockettimeoutexception: read timed out @ redis.clients.util.redisinputstream.ensurefill(redisinputstream.java:201) @ redis.clients.util.redisinputstream.readbyte(redisinputstream.java:40) @ redis.clients.jedis.protocol.process(protocol.java:141) @ redis.clients.jedis.protocol.read(protocol.java:205) @ redis.clients.jedis.connection.readprotocolwithcheckingbroken(connection.java:297) @ redis.clients.jedis.connection.getbinarymultibulkreply(connection.java:233) @ redis.clients.jedis.jedis.keys(jedis.java:185) @ org.v11.redis_mongo_task.updateapp.jobdetail(updateapp.java:23) @ org.v11.redis_mongo_task.updateapp.main(updateapp.java:42) ... 5 more caused by: java.net.sockettimeoutexception: read timed out @ java.net.socketinputstream.socketread0(native method) @ java.net.socketinputstream.read(socketinputstream.java:150) @ java.net.socketinputstream.read(socketinputstream.java:121) @ java.net.socketinputstream.read(socketinputstream.java:107) @ redis.clients.util.redisinputstream.ensurefill(redisinputstream.java:195) ... 13 more

what happened redis? why can work in single thread?

according this answer, single jedis instance not threadsafe. have use jedispool multithreading. can read here on how use , here set max connections , happen if connections occupied.

i'm posting links since 2 of them answers should credit , 1 github official repo, if gets updated should reflected here too.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -