jedis throws Unexpected end of stream

6,698 views
Skip to first unread message

liwei jia

unread,
May 18, 2015, 8:00:52 AM5/18/15
to jedis...@googlegroups.com
I use jedis to access Redis but sometimes it throws JedisConnection,message is Unexpected end of stream  ,can anyone help me ? 
the followering is my code:

 public static JedisPool jedisPool = null;

    public static void init(){
         jedisPool =new JedisPool(new GenericObjectPoolConfig(), REDIS_HOST, REDIS_PORT, Protocol.DEFAULT_TIMEOUT, REDIS_PASS,
                 Protocol.DEFAULT_DATABASE, null);
    }

    public static void set(String key,String value){
        try(Jedis jedis = jedisPool.getResource()){
            jedis.set(key, value);
            logger.debug("redis set {}:{}", key, value);
        }
    }


Jonathan Leibiusky

unread,
May 18, 2015, 8:02:38 AM5/18/15
to jedis...@googlegroups.com

Hi! When does it throw that exception?


--
You received this message because you are subscribed to the Google Groups "Jedis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jedis_redis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

liwei jia

unread,
May 18, 2015, 10:10:16 AM5/18/15
to jedis...@googlegroups.com
when invoke  the static set method,but it is very strange that it does not occures every time.I google for days someone said that it may be concurrent problem but jedisPool is thread safe according to the document,so I am totaly confused. 

Marcos NiLs

unread,
May 18, 2015, 10:33:18 AM5/18/15
to jedis...@googlegroups.com

liwei, 

Can you send us the whole stacktrace and your current redis configuration?

Thx, 

Marcos.

liwei jia

unread,
May 18, 2015, 10:00:20 PM5/18/15
to jedis...@googlegroups.com
I use jedis in an akka project ,the version is 2.6.2,the redis server is ,the full stacktrace is like this:

redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:198)
at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40)
at redis.clients.jedis.Protocol.process(Protocol.java:128)
at redis.clients.jedis.Protocol.read(Protocol.java:192)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:282)
at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:201)
at redis.clients.jedis.Connection.getBulkReply(Connection.java:190)
at redis.clients.jedis.Jedis.get(Jedis.java:93)
at net.qihoo.life.airspider.cnpm.infrastructure.redis.RedisCache.get(RedisCache.java:50)
at net.qihoo.life.airspider.fusion.actor.AirFusion.fusion(AirFusion.java:84)
at net.qihoo.life.airspider.fusion.actor.AirFusion.lambda$onReceive$20(AirFusion.java:54)
at net.qihoo.life.airspider.fusion.actor.AirFusion$$Lambda$3/1208477110.call(Unknown Source)
at akka.dispatch.Futures$$anonfun$future$1.apply(Future.scala:94)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:41)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:401)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

The redis info looks like this:
# Server
redis_version:2.8.16
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:81f619288ce889d0
redis_mode:standalone
os:Linux 2.6.32-2.0.0.8-6 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:7399
run_id:e3134a2121941024d118941d652686328750be4b
tcp_port:6393
uptime_in_seconds:1117891
uptime_in_days:12
hz:10
lru_clock:5937324
config_file:/data1/redis6393/redis6393.conf

# Clients
connected_clients:9
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:2150279040
used_memory_human:2.00G
used_memory_rss:1320697856
used_memory_peak:2150786104
used_memory_peak_human:2.00G
used_memory_lua:33792
mem_fragmentation_ratio:0.61
mem_allocator:jemalloc-3.6.0

# Persistence
loading:0
rdb_changes_since_last_save:5538867
rdb_bgsave_in_progress:0
rdb_last_save_time:1430882798
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:1
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_current_size:1314792821
aof_base_size:0
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0

# Stats
total_connections_received:529479
total_commands_processed:12866115
instantaneous_ops_per_sec:0
rejected_connections:0
sync_full:1
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:4325335
keyspace_misses:1339637
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:125

# Replication
role:master
connected_slaves:1
slave0:ip=10.138.104.248,port=6393,state=online,offset=1316357364,lag=1
master_repl_offset:1316357364
repl_backlog_active:1
repl_backlog_size:2147483648
repl_backlog_first_byte_offset:2
repl_backlog_histlen:1316357363

# CPU
used_cpu_sys:124.28
used_cpu_user:92.29
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Keyspace
db0:keys=4407,expires=0,avg_ttl=0



在 2015年5月18日星期一 UTC+8下午10:33:18,Marcos NiLs写道:

Marcos NiLs

unread,
May 18, 2015, 10:06:36 PM5/18/15
to jedis...@googlegroups.com
can you do a `config get *` and paste the result here plz?

Thx!.

liwei jia

unread,
May 18, 2015, 10:20:40 PM5/18/15
to jedis...@googlegroups.com
like this ?

dbfilename
dump6393.rdb
requirepass
71950eda3513b86d
masterauth
71950eda3513b86d
unixsocket
/tmp/redis6393.sock
logfile
/data1/redis6393/redis.log
pidfile
/data1/redis6393/redis.pid
maxmemory
50000000000
maxmemory-samples
3
timeout
30
tcp-keepalive
0
auto-aof-rewrite-percentage
500
auto-aof-rewrite-min-size
20000000000
hash-max-ziplist-entries
512
hash-max-ziplist-value
64
list-max-ziplist-entries
512
list-max-ziplist-value
64
set-max-intset-entries
512
zset-max-ziplist-entries
128
zset-max-ziplist-value
64
hll-sparse-max-bytes
3000
lua-time-limit
5000
slowlog-log-slower-than
1000
latency-monitor-threshold
0
slowlog-max-len
1024
port
6393
tcp-backlog
511
databases
16
repl-ping-slave-period
10
repl-timeout
60
repl-backlog-size
repl-backlog-ttl
0
maxclients
10000
watchdog-period
0
slave-priority
100
min-slaves-to-write
0
min-slaves-max-lag
10
hz
10
no-appendfsync-on-rewrite
yes
slave-serve-stale-data
yes
slave-read-only
yes
stop-writes-on-bgsave-error
no
daemonize
yes
rdbcompression
yes
rdbchecksum
yes
activerehashing
yes
repl-disable-tcp-nodelay
no
aof-rewrite-incremental-fsync
yes
aof-load-truncated
yes
appendonly
yes
dir
/data1/redis6393
maxmemory-policy
volatile-lru
appendfsync
everysec
save

loglevel
notice
client-output-buffer-limit
normal 0 0 0 slave 0 0 0 pubsub 33554432 8388608 60
unixsocketperm
755
slaveof

notify-keyspace-events

bind


在 2015年5月19日星期二 UTC+8上午10:06:36,Marcos NiLs写道:

Marcos NiLs

unread,
May 18, 2015, 10:28:06 PM5/18/15
to jedis...@googlegroups.com
Yes. 

Try setting the "timeout" option to 0 and see if the problem gets fixed. 

Marcos.

liwei jia

unread,
May 18, 2015, 10:41:00 PM5/18/15
to jedis...@googlegroups.com
Yes,It fixed!
You are my hero of May!

在 2015年5月19日星期二 UTC+8上午10:28:06,Marcos NiLs写道:

Marcos Lilljedahl

unread,
May 18, 2015, 10:45:13 PM5/18/15
to jedis...@googlegroups.com
Anytime!. 

In case you want to read further information about what was happened you can take a look at this issue:



Marcos.
Reply all
Reply to author
Forward
0 new messages