Search code examples
amazon-web-servicesnode-redmosquitto

What server address (mosquitto broker url) should I use to connect node-red to mosquitto?


My situation is currently

  1. I have two computers. One is my computer, the other is Amazon Web Services. Node-red is installed on my computer, and mosquitto is installed on Amazon Web Services (Photo 1).
  2. I run mosquitto on Amazon Web Services, and type mosquitto_sub -t "test" for receive data.(photo 2)
  3. I need to enter 'server' (mosquitto broker url) and 'topic' in node-red to send data from node-red to mosquitto. Currently I have entered 172.26.12.244:1880 and 'test'. But node-red and mosquitto are not connected. (Photo 3)

Questions

  1. Photo4 is the console screen for Amazon Web Services. When I type ifconfig, I get several ip addresses. What ip should I enter in 'server'? (photo 4)
  2. Are all the steps I've done so far right?
  3. Is it dangerous to upload my IP as I do now? I am a beginner studying about studying server.

ps)

Over time, a connection is made from node-red, so when I send data from node-red, I see a "Successfully injected" message. But in mosquitto no messages can be seen. My guess is that when I send data from node-red, that data should be output to the mosquitto screen. Isn't it? (photo5)

(photo 1) enter image description here

(photo 2) enter image description here

(photo 3) enter image description here

(photo 4) enter image description here

(photo 5) enter image description here


Solution

  • There are several questions here so will try answering one by one if any question is missed out comment to ask.

    1. The ip you have used for mosquitto server is wrong you need to find the external ip which you can find in the aws EC2 web console
    2. ifconfig does not give you the external ip
    3. It is dangerous to reveal your ip only if you have given public access to the ip
    4. As @Rafael Muynarsk pointed once you have the external ip make sure the security group allows the connection from your computer to the mosquitto on the port mosquitto is running.