Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems like server has closed the connection #76

Closed
mathieucarbou opened this issue Jan 10, 2011 · 6 comments
Closed

It seems like server has closed the connection #76

mathieucarbou opened this issue Jan 10, 2011 · 6 comments

Comments

@mathieucarbou
Copy link

Hi,

We are using redis in a web application. The Jedis poll is retreived through JNDI. Using Jetty, we have configured it like this:

<New class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg>redis/jaxspot</Arg>
    <Arg>
        <New class="redis.clients.jedis.JedisPool">
            <Arg>
                <New class="org.apache.commons.pool.impl.GenericObjectPool$Config">
                    <Set type="int" name="minIdle">4</Set>
                    <Set type="int" name="maxActive">10</Set>
                </New>
            </Arg>
            <Arg>127.0.0.1</Arg>
            <Arg type="int">6379</Arg>
        </New>
    </Arg>
</New>

So this is basically a pool of 4 to 10 connections. In our application the first requests goes well. But when we wait about 2-3 minutes and we refresh the page, redis crashed. The following code:

Jedis jedis = pool.getResource();
[...]
String v = jedis.get(s);

throws the exception:

Caused by: redis.clients.jedis.JedisException: It seems like server has closed the connection.
at redis.clients.util.RedisInputStream.readLine(RedisInputStream.java:90)
at redis.clients.jedis.Protocol.processBulkReply(Protocol.java:83)
at redis.clients.jedis.Protocol.process(Protocol.java:66)
at redis.clients.jedis.Protocol.read(Protocol.java:121)
at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:163)
at redis.clients.jedis.Connection.getBulkReply(Connection.java:153)
at redis.clients.jedis.Jedis.get(Jedis.java:68)
at net.playtouch.jaxspot.module.caching.redis.RedisTransactionalCache$1.execute(RedisTransactionalCache.java:28)

@mathieucarbou
Copy link
Author

Jedis: 1.5.0
Redis: redis-2.2.0-rc2.tar.gz

@yaourt
Copy link
Contributor

yaourt commented Jan 14, 2011

You need to configure the pool with "testOnBorrow = true" ...
Redis server is shuting down the connections after a while, and you need to test if the connection is still useable on the client side ...

@mathieucarbou
Copy link
Author

Thank you it works!

@nafeger
Copy link

nafeger commented Feb 8, 2011

Just to beat a dead horse a bit, might a good pool setup for a long running server process be as simple as:

JedisPoolConfig config = new JedisPoolConfig();
config.setTestOnBorrow(true);
this.pool = new JedisPool(config, this.redisServer, this.redisPort);

@willzhai
Copy link

willzhai commented Apr 2, 2011

when i use redis-2.2.2 and jedis-1.5.2

static {
if (pool == null) {
redis.clients.jedis.JedisPoolConfig config = new redis.clients.jedis.JedisPoolConfig();
config.maxActive = 20;
config.maxIdle = 10;
config.maxWait = 1000;
config.testOnBorrow = true;
pool = new JedisPool(config, REDISHOST, REDISPORT);
}
}

i got the following and do not know why,~~~~(>_<)~~~~ :

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

java.util.NoSuchElementException: Could not create a validated object, cause: ValidateObject failed org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1203)
redis.clients.util.Pool.getResource(Pool.java:20)

@yychaoV5
Copy link

jedis with some error: when redis server send back "Protocol error" message , the server will close socket; but jedis Protocol.java just throw a JedisDataException exception and ignored tcp close segment; so if you reuse this connection, jedis will throw an exception with "It seems like server has closed the connection" message.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants