java.net.SocketException: Too many open files

822 views
Skip to first unread message

Rajitha R

unread,
Aug 26, 2011, 7:47:54 AM8/26/11
to Jedis
Hi all,

I have given a large file as input to jedis client which is connected
to redis server, in the sense,i have to insert several key-values into
the database.This is how i am inserting values into the database.

For putting value into the database:
****************************************
client.setHost("localhost");
client.setPort(6380);
client.connect();
jedis.set(impid,impid);
client.disconnect();

And for retrieving data :
**************************
client.setHost("localhost");
client.setPort(6380);
client.connect();
value = jedis.get(key);
client.disconnect();

To connect to the redis server, i used the connect() method as i
needed to had my own configuration in redis.conf.
.I was able to run successfully for a smaller file but not with a
larger one.I am getting the following error for a larger file input.

redis.clients.jedis.exceptions.JedisConnectionException:
java.net.SocketException: Too many open files

I am very new to redis.Kindly help.
Thanks in Advance.
Rajitha

Jakub Białek

unread,
Aug 26, 2011, 8:15:44 AM8/26/11
to jedis...@googlegroups.com
You don't have to create client and disconnect after each operation. Simply create client once and use it for all yours operations:
client.setHost("localhost");
client.setPort(6380);
jedis.set(...);
jedis.set(...);
jedis.set(...);
......
jedis.set(...);
client.disconnect();

the same approach can be used to get part - it can be even the same client used in set part.
Common usage pattern is to create client (or pool of clients) at the startup and use it till application shutdown.

Best regards,
Ragnor

rajitha r

unread,
Aug 26, 2011, 8:23:31 AM8/26/11
to jedis...@googlegroups.com
Thanks a lot..

2011/8/26 Jakub Białek <ragn...@gmail.com>



--
Regards,

Rajitha.R

Reply all
Reply to author
Forward
0 new messages