0

I am trying to send messages between two local PC (Windows OS). I have connected to these PC using LAN connection. The RabbitMQ server is installed on 10.100.94.25 PC. I am trying to create a connection from 10.100.94.28 PC. I have ping to my rabbit MQ server PC (10.100.94.25) from Client PC (10.100.94.28) using windows command prompt. It was successful. But, when I try to create a connection from code, it is not working. Please check my code and error log bellow. the error is telling me that "timeout error". what should I do?

I have successfully sent and received a message from the same PC. That means, when I use localhost as host, it works perfectly. Then what is the tiny touch I am missing here for remote access?

connectionFactory = new ConnectionFactory();
connectionFactory.setUsername("shoshi");
connectionFactory.setPassword("shoshi");
connectionFactory.setHost("10.100.94.25");
connectionFactory.setPort(5672);
connection = connectionFactory.newConnection(); // this is 451 number line

error:

May 01, 2016 6:00:35 PM com.chat.UI initRabbitMQ
SEVERE: null
java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:714)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:760)
    at com.chat.UI.initRabbitMQ(UI.java:451)
    at com.chat.UI.<init>(UI.java:48)
    at com.chat.UI$8.run(UI.java:405)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Shoshi
  • 2,254
  • 1
  • 29
  • 43

3 Answers3

2

I was guessing that the 5672 port is open or not. Or the firewall is blocking it or not. thanks to cantSleepNow and Thomas for their instruction.

So, what I have done? I just check the port number using telnet. the command is telnet IP_ADDRESS PORT_NUMBER. if telnet is not recognized as a command, then you have to enable it. follow the instruction bellow:

To install Telnet, please follow these instructions:

  1. Click Start then select Control Panel.
  2. Select Programs and Features.
  3. Select Turn Windows features on or off.
  4. Select the Telnet Client option.
  5. Click OK.

or, follow this link

I was able to get a response by using telnet localhost 5672 command. but not with telnet 10.100.94.25 5672 command.

Also, from THIS POST I get that:

  • connection refused means that nothing is running on that port
  • accepted means that something is running on that port
  • timeout means that a firewall is blocking access

And my error log says that java.net.ConnectException: Connection timed out: connect

So, now I am sure that it is a firewall issue. Then I just open erlang for remote access by following THIS TUTORIAL. And now it is working.

To know your PC's IP adress just type ipconfig using CMD.

Community
  • 1
  • 1
Shoshi
  • 2,254
  • 1
  • 29
  • 43
1

This is most probably a (Windows) firewall issue, make sure that connections to that port are allowed.

Thomas
  • 11,272
  • 2
  • 24
  • 40
0

With my ActiveMQ setup, the way I usually check my connection is:

I have a tester EJB which subscribes to a topic on the ActiveMQ system. I start my ActiveMQ system, and then run the EJB on my own server on another system. If the connection is all fine, then this EJB shows up as a consumer on the ActiveMQ dashboard. This method ensures connection setup without any nitty gritty problems with setting up the connection. Since you ping is working, this test should ideally go through successfully.

If success, you need to make sure your producer is working fine. If failure, you know for sure that the connection is not setup properly.