RocketMQ一直打印RocketmqRemoting closeChannel: close the connection to remote address[] result: true

交代一下背景:java

RocketMQ服務端搭建在ECS上面(問題就出在這裏)git

SpringBoot應用根據官網Demo(參考:https://github.com/apache/rocketmq-spring/tree/master/rocketmq-spring-boot-samples)構建github

 

項目啓動的時候就開始打印遠程地址爲空,發送消息失敗而且也打印遠程地址爲空:spring

RocketmqRemoting: closeChannel: close the connection to remote address[] result: true

 

remote address是空的,開始覺得是項目的rocketmq.name-server配置有問題,經過獲取RocketMQTemplate的namesrvAddr發現沒問題,代碼以下apache

rocketMQTemplate.getProducer().getNamesrvAddr()

 

再看一下SendCallback的Throwable,錯誤信息以下:服務器

org.apache.rocketmq.client.exception.MQClientException: Send [1] times, still failed, cost [5325]ms, Topic: ADDRESS_PART_TOPIC, BrokersSent: [broker-a] See http://rocketmq.apache.org/docs/faq/ for further details.
    at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:638) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.access$300(DefaultMQProducerImpl.java:90) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl$3.run(DefaultMQProducerImpl.java:491) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) at java.util.concurrent.FutureTask.run(FutureTask.java) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.4:10911> failed at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeAsync(NettyRemotingClient.java:537) at org.apache.rocketmq.client.impl.MQClientAPIImpl.sendMessageAsync(MQClientAPIImpl.java:484) at org.apache.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:441) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:811) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:557) ... 8 more

看到192.168.0.4:10911這個地址就知道問題是出在RocketMQ的Broker服務,192.168.0.4是ECS內網IP地址spring-boot

這裏再看一下Broker啓動信息:測試

 

The broker[broker-a, 192.168.0.4:10911] boot success. serializeType=JSON and name server is X.X.X.X:9876

 

肯定問題是brokerIP是服務器的內網IP致使producer沒法與之創建鏈接致使spa

 

解決方法:.net

 

//查看broker配置
sh ./bin/mqbroker -m

 

在conf/broker.conf配置文件中增長

 

brokerIP1=X.X.X.X(公網IP)

 

再次啓動broker服務

nohup sh bin/mqbroker -n 111.231.XX.XX:9876 -c conf/broker.conf autoCreateTopicEnable=true &

啓動結果:

The broker[broker-a, X.X.X.X:10911] boot success. serializeType=JSON and name server is 106.12.x.x:9876

重啓本地項目,測試producer發送消息成功

相關文章
相關標籤/搜索