说明
按RabbitMQ官网教程搭建Go语言环境下的MQ demo时,遇到一直连接不上的问题,报错如下:
Failed to connect to RabbitMQ: dial tcp 192.168.200.11:5672: connectex: A connection attempt failed because the connected party did not properly respond after a per
iod of time, or established connection failed because connected host has failed to respond.
exit status 1
原因为远程的 Linux虚拟机上的5672端口未开启,连接请求被拦截,须开启Linux上的5672端口,同时开启15672端口以便在本机使用RabbitMQ Management
firewall-cmd --zone=public --add-port=5672/tcp --permanent
firewall-cmd --zone=public --add-port=15672/tcp --permanent
firewall-cmd --zone=public --reload
问题解决