0

I've just started studying rabbitmq. So while just doing some basic stuff in rabbitmq with java client am getting the below issue

Exception in thread "main" java.util.concurrent.TimeoutException
    at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:76)
    at com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:110)
    at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
    at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:372)
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:298)
    at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:58)
    at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:103)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:877)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:839)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:797)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:930)
    at com.sharique.jobs.HelloWorldProducer.produce(HelloWorldProducer.java:32)

and below is the code to create a connection

ConnectionFactory factory = new ConnectionFactory();

                factory.setUsername("guest");
                factory.setPassword("guest");
                factory.setHost("localhost");
                factory.setPort(5672);
Connection connection = factory.newConnection();

And one more thing i.e., rabbitmq server is running.

Please help

Sharique
  • 781
  • 5
  • 12
  • 33
  • Is there a blocking firewall ? What does telnet localhost 5672 do ? Does it get in ? – Ramachandran.A.G Jan 29 '17 at 15:51
  • Not sure i get it , in the client code you are connecting to a local instance of RabbitMQ. What is this host 0.0.22.40 ? Does telnet localhost 5672 connect ? – Ramachandran.A.G Jan 29 '17 at 15:56
  • I don't know exactly what actually it is... And I also checked, firewall is turned off – Sharique Jan 29 '17 at 15:56
  • =INFO REPORT==== 29-Jan-2017::21:30:09 === accepting AMQP connection <0.22997.0> (127.0.0.1:55865 -> 127.0.0.1:5672) =WARNING REPORT==== 29-Jan-2017::21:30:17 === closing AMQP connection <0.22997.0> (127.0.0.1:55865 -> 127.0.0.1:5672): client unexpectedly closed TCP connection This is what it prints in rabbitmq log when I run my program – Sharique Jan 29 '17 at 16:01
  • Sorry... Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Connection closed by foreign host. Am getting this response – Sharique Jan 29 '17 at 16:18
  • I am pretty sure it is some kind of a network firewall or similar issue. Basically the application connects and gets terminated externally. Can you try disabling the firewall and check ? https://github.com/rabbitmq/rabbitmq-tutorials/issues/101 – Ramachandran.A.G Jan 29 '17 at 16:20
  • yeah I even saw that post and I have checked it...in my local system firewall is turned off – Sharique Jan 29 '17 at 16:29
  • Yes you were ryt...there was some kind of network issue and it turned out a DNS issue...its resolved. Thanks for the help – Sharique Jan 29 '17 at 17:33

2 Answers2

0

Set the virtual host setVirtualHost like:

String uri = System.getenv("URL");
if (uri == null) uri = "amqp://guest:guest@localhost";

ConnectionFactory factory = new ConnectionFactory();
factory.setUri(uri);
.
.
factory.setVirtualHost("/");
Connection connection = factory.newConnection();

You could also set setConnectionTimeout.

Lovisa Johansson
  • 9,721
  • 1
  • 16
  • 20
-3

cmd

typing " netstat /an | find "5672" " on cmd. if that port is listening, change port or restart sever

csi2
  • 1
  • 1
  • find: 5672: No such file or directory This is the response which I got and I have restarted the server many a times... and I blv this is the default port, ryt? – Sharique Jan 29 '17 at 16:11