activeMQ连接错误--- javax.jms.JMSException: Could not connect to broker URL: tcp://192.168.217.129:61616

最近在学习activeMQ时,启动本地项目过程中遇到了连接错误,我是在linux虚拟机上开启的active MQ服务,通过本地程序进行测试,控制台错误信息如下:

Exception in thread "main" javax.jms.JMSException: Could not connect to broker URL: tcp://192.168.217.129:61616. Reason: java.net.ConnectException: Connection timed out: connect
	at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36)
	at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:374)
	at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:304)
	at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:244)
	at mavenTest.activeMQ.TestMQProducerQueue.testMQProducerQueue(TestMQProducerQueue.java:25)
	at mavenTest.activeMQ.TestMQProducerQueue.main(TestMQProducerQueue.java:18)
Caused by: 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:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:525)
	at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:488)
	at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55)
	at org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:169)
	at org.apache.activemq.transport.InactivityMonitor.start(InactivityMonitor.java:52)
	at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64)
	at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72)
	at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64)
	at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64)
	at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:354)
	... 4 more

可以看到连接超时了,然后在本地telnet了url:

telnet 192.168.217.129 61616

发现连接确实不通:

然后网上搜索了各种原因都排除之后,突然想到linux防火墙的问题,61616端口有可能被禁用了;

查看/etc/sysconfig/iptables,添加61616端口可用

activeMQ连接错误--- javax.jms.JMSException: Could not connect to broker URL: tcp://192.168.217.129:61616_第1张图片

修改保存后执行 service iptables restart,使配置生效,开启activeMQ,再测试,发现已经可以连接并测试了。

测试结果:

activeMQ连接错误--- javax.jms.JMSException: Could not connect to broker URL: tcp://192.168.217.129:61616_第2张图片

你可能感兴趣的:(activeMQ连接错误--- javax.jms.JMSException: Could not connect to broker URL: tcp://192.168.217.129:61616)