Connect to MQTT broker (aedes running on AWS) from public client

Hi,

I am pretty much new to node-red but by reading blogs and forums , I was able to setup node-red.

I have installed node-red on AWS EC2 - Windows Instance and enable IIS Manager and installed websockets,enabling websockets through Server Manager was necessary to have node-red started fully on EC2.(before enable websockets, node-red was getting disconnected after login)

Now, the task is to run MQTT broker on the AWS EC2 instance and connect to it using public clients.

I have installed aedes broker and configure following:
MQTT port: 1884
WS port : 8080
Have entered - user and password in security,my flow is attached.
Following is the details of netstat command and tasklist running on ports

TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 3408
TCP 127.0.0.1:8080 127.0.0.1:51435 ESTABLISHED 3408
TCP 127.0.0.1:51435 127.0.0.1:8080 ESTABLISHED 3408

Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
node.exe 3408 RDP-Tcp#102 2 66,300 K

Now can when i try to connect by any client like google lens or hiveMQ client I am getting error.

Can anybody tell what mistake I am doing ?

As I am able to subscribe to Aedes MQTT broker on localhost, how can I connect Aedes MQTT broker through public clients.

Thanks and Regards,

This seems to be more of an AWS question than Node Red :grinning: I would suggest looking at the tutorial on AWS about creating a VPC (Virtual Private Cloud) and then you will be able to open the necessary ports to enable access to your broker

Hi,
@mtoko I think you are partially correct, but my question goes to all those people who have implemented MQTT Broker (using AEDES module) on Node-red , it can be AWS or any other Server.

As I have configured incoming messages in security configurations in AWS ( custom TCP ports like : 8080 , 1883,1883 and others)

Do you think Launching EC2 under a VPC on AWS will provide a solution to this (My instance is configured on EC2-classic )?

If you are sure about the solution, can you share any links or keywords which can help..

Thanks and Regards

@divyansh
I have Ubuntu instances, so can't be much help with the Windows instance. It took a some time to get set up but this is the tutorial I used
https://docs.aws.amazon.com/vpc/latest/userguide/getting-started-ipv4.html#getting-started-create-vpc

Atlast, I have got it working.

The main problems were

  1. I was using IIS in which I wasn't able to configure proxy for MQTT.I disabled IIS, downloaded NGINX .
    To test if I am able to reach the website, I changed the default listen 80 ( HTTP) to some other port 8080.
    On opening 27.0.0.1:8080 ,I was able to see the default page of NGINX, with this I was sure that i am on right path.

  2. Now the above, was to be checked with public client.On browser, I typed my domainname:8080 , I wasn't able to see.
    For this step : I set my in bound ports (Your EC2 Instance >security Groups) in AWS to allow tcp input and output connection on port 8080.
    PS: Not sure if outgoing rules are to necessary be set .

  3. I set windows firewall on by Ec2 instance to allow inbound rules for all connections types to allow incoming data from port 8080.

4)Great!! by these simple 3 steps , I was able to setup my proxy server using NGINX.

  1. Now for MQTT , went through following tutorial and everything worked.I didn't change any setting on my node-red.
    [https://www.nginx.com/blog/nginx-plus-iot-load-balancing-mqtt/#match]

Trick : Before setting up everything on Cloud Instance, just check everything on your local machine.
Then simply copy and paste the settings.js file of node-red , config file of nginx ( with some changes in path).This will save you a lot of lag which might delay your development in cloud

Happy Coding!!

Regards.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.