前提:使用docker安装了rocketmq,docker安装请查看上一篇 docker快速部署rocketmq
1、测试发送消息,错误信息如下:
Caused by: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to <172.18.0.4:10911> failed
at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:392)
at org.apache.rocketmq.client.impl.MQClientAPIImpl.sendMessageSync(MQClientAPIImpl.java:465)
at org.apache.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:449)
at org.apache.rocketmq.client.impl.MQClientAPIImpl.sendMessage(MQClientAPIImpl.java:403)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:831)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:557)
... 4 more
16:21:29.038 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[] result: true
2、错误原因:连接超时,172.18.0.4是内网ip。
3、解决方案:进入容器,修改配置:
docker exec -it --user root rmqbroker bash
cd ../conf
vi broker.conf
配置信息如下:
4.重启broker,修改生效,即可以正常访问。