Amazon ec2 无法将EC2实例公共IP分配给MOSQUITO MQTT代理

Amazon ec2 无法将EC2实例公共IP分配给MOSQUITO MQTT代理,amazon-ec2,mqtt,mosquitto,Amazon Ec2,Mqtt,Mosquitto,我已经在其中一个EC2实例(ubuntu)中安装了Mosquitto MQTT,并且代理在localhost中运行良好 我可以在本地计算机和另一个EC2实例中发布/订阅(两个EC2都在同一个子网172.31.X.X中) 现在,我想从外部PC连接代理(发布/订阅)。因此,我尝试将代理IP配置为EC2实例公共IP VirtualBox:cat /etc/mosquitto/mosquitto.conf # Place your local configuration in /etc/mosquitt

我已经在其中一个EC2实例(ubuntu)中安装了Mosquitto MQTT,并且代理在localhost中运行良好

我可以在本地计算机和另一个EC2实例中发布/订阅(两个EC2都在同一个子网172.31.X.X中)

现在,我想从外部PC连接代理(发布/订阅)。因此,我尝试将代理IP配置为EC2实例公共IP

VirtualBox:cat /etc/mosquitto/mosquitto.conf
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
listener 1883 50.24.39.66
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
VirtualBox:
VirtualBox:sudo mosquitto -c /etc/mosquitto/mosquitto.conf
1495801790: mosquitto version 1.4.8 (build date Fri, 19 Feb 2016 12:03:16 +0100) starting
1495801790: Config loaded from /etc/mosquitto/mosquitto.conf.
1495801790: Opening ipv4 listen socket on port 1883.
1495801790: Error: Cannot assign requested address
carun@carun-VirtualBox:~$
但是,在重新启动代理时,出现上述错误“无法分配请求的地址”

到目前为止

  • 允许(内部/外部)对EC2的所有访问
  • EC2中已禁用防火墙
  • -允许对EC2安全组的所有安全级别访问
但是运气不好

那么问题,

  • 如何将EC2公共IP分配给代理
  • 我如何在世界的另一端访问MQTT代理

  • 提前感谢您的帮助

    listener
    行的末尾删除ip地址(50.24.39.66)(或只删除整行)要允许MOSQUITO绑定到所有可用IP地址

    请从侦听器行中删除IP地址,它将绑定到所有可用IP地址。因此,我需要替换侦听器进行绑定?默认情况下,代理将在EC2的私有IP上运行正确…我们必须更新到公共IP,以便外部世界访问,rite?如果我错了,请纠正我。@hardillb说你应该把这句话改为“listener 1883”,而不是“listener 1883 50.24.39.66”。然后它将在所有的IP接口上进行监听。谢谢,这很有效!