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

Connection refused #101

Closed
SergioMendes93 opened this issue Jul 17, 2017 · 1 comment
Closed

Connection refused #101

SergioMendes93 opened this issue Jul 17, 2017 · 1 comment

Comments

@SergioMendes93
Copy link

Hello everyone, I'm running the following code to fill a Redis server quickly:

public static void main(String[] args) { 
      Jedis jedis = new Jedis(args[0], Integer.parseInt(args[1])); 
        long fiveMega = 524288000; //500mb
        long correspondentValue = 2097151; //Value to get 500mb being consumed
        long memoryRequirement = Long.parseLong(args[2],10); 

        long value = (memoryRequirement * correspondentValue) / fiveMega; 

        Pipeline pipeline = jedis.pipelined();
        for (long i = 0 ; i < value; i++) {
                pipeline.sadd("key"+i, "value");
        }
        pipeline.sync();
   } 

However sometimes I get the connection exception bellow but other times it works and I can't understand why. The ports and everything are correct.

By the way, if there is another way to fill up a redis server quickly with junk data I would appreciate to see if there is no error! Thanks for the help!

exit status 1: Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused (Connection refused)
at redis.clients.jedis.Connection.connect(Connection.java:148)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:75)
at redis.clients.jedis.Connection.sendCommand(Connection.java:77)
at redis.clients.jedis.BinaryClient.sadd(BinaryClient.java:325)
at redis.clients.jedis.Client.sadd(Client.java:242)
at redis.clients.jedis.PipelineBase.sadd(PipelineBase.java:474)
at redis.clients.jedis.Pipeline.sadd(Pipeline.java:8)
at fillRedis.main(fillRedis.java:32)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at redis.clients.jedis.Connection.connect(Connection.java:142)
... 7 more

@ushachar
Copy link
Collaborator

Hi @SergioMendes93 - You should probably ask this question on the Jedis repo page. This repository is for the Redis Dockerfile.
In any case:

  • For a command line tool for quickly filling up a Redis instance see memtier_benchmark
  • In order to debug your connectivity issues you should probably take a look using tcpdump....

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

2 participants