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

**URL:** <https://discourse.nodered.org/t/connect-to-mqtt-broker-aedes-running-on-aws-from-public-client/25732>\
**Category:** General\
**Created:** [29 April 2020 10:33 UTC](https://discourse.nodered.org/t/connect-to-mqtt-broker-aedes-running-on-aws-from-public-client/25732 "2020-04-29T10:33:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![divyansh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/divyansh/32/20923_2.png) [@divyansh](https://discourse.nodered.org/u/divyansh)\
**Post date:** [29 April 2020 10:33 UTC](https://discourse.nodered.org/t/connect-to-mqtt-broker-aedes-running-on-aws-from-public-client/25732/1 "2020-04-29T10:33:33Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4e3df160a3fc840ad471f4de1731526a2cdfb690.png)

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,

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [29 April 2020 10:43 UTC](https://discourse.nodered.org/t/connect-to-mqtt-broker-aedes-running-on-aws-from-public-client/25732/2 "2020-04-29T10:43:18Z")

</div>

This seems to be more of an AWS question than Node Red 😀 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

---

<div class="post-metadata">

**Author:** ![divyansh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/divyansh/32/20923_2.png) [@divyansh](https://discourse.nodered.org/u/divyansh)\
**Post date:** [29 April 2020 11:42 UTC](https://discourse.nodered.org/t/connect-to-mqtt-broker-aedes-running-on-aws-from-public-client/25732/3 "2020-04-29T11:42:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mtoko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mtoko/32/138_2.png) [@mtoko](https://discourse.nodered.org/u/mtoko)\
**Post date:** [29 April 2020 13:41 UTC](https://discourse.nodered.org/t/connect-to-mqtt-broker-aedes-running-on-aws-from-public-client/25732/4 "2020-04-29T13:41:38Z")

</div>

@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](https://docs.aws.amazon.com/vpc/latest/userguide/getting-started-ipv4.html#getting-started-create-vpc)

---

<div class="post-metadata">

**Author:** ![divyansh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/divyansh/32/20923_2.png) [@divyansh](https://discourse.nodered.org/u/divyansh)\
**Post date:** [30 April 2020 08:34 UTC](https://discourse.nodered.org/t/connect-to-mqtt-broker-aedes-running-on-aws-from-public-client/25732/5 "2020-04-30T08:34:21Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 May 2020 08:34 UTC](https://discourse.nodered.org/t/connect-to-mqtt-broker-aedes-running-on-aws-from-public-client/25732/6 "2020-05-14T08:34:25Z")

</div>

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