Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with bridging mosquitto MQTT broker to AWS IoT #2889

Closed
rahulpandey-98 opened this issue Sep 7, 2023 · 4 comments
Closed

Issues with bridging mosquitto MQTT broker to AWS IoT #2889

rahulpandey-98 opened this issue Sep 7, 2023 · 4 comments

Comments

@rahulpandey-98
Copy link

A Mosquitto MQTT broker bridged to AWS IoT have been made using the information provided on
https://aws.amazon.com/blogs/iot/how-to-bridge-mosquitto-mqtt-broker-to-aws-iot/

The configuration, I am using for my mosquitto MQTT broker is as follows:

============================================================

Bridge to AWS IOT

============================================================

connection awsiot

#<Paste your AWS IoT Core ATS endpoint retrieved from the AWS CLI in the form of xxxxxxxxxxxxxxx-ats.iot..amazonaws.com:8883

address a3fu7wrc8e12x7-ats.iot.us-east-1.amazonaws.com:8883

Specifying which topics are bridged and in what fashion

topic $aws/things/+/shadow/update out 1
topic $aws/things/+/bytepayload/update out 1
topic $aws/things/+/shadow/update/delta in 1

Setting protocol version explicitly

bridge_protocol_version mqttv311
bridge_insecure false

Bridge connection name and MQTT client Id, enabling the connection automatically when the broker starts.

cleansession true
clientid bridgeawsiot
start_type automatic
notifications false
log_type all

#Adding broker config
allow_anonymous true
listener 1883

============================================================

Certificate based SSL/TLS support

============================================================

#Path to the rootCA
bridge_cafile /etc/mosquitto/certs/rootCA.pem

Path to the PEM encoded client certificate

bridge_certfile /etc/mosquitto/certs/cert.crt

Path to the PEM encoded client private key

bridge_keyfile /etc/mosquitto/certs/private.key

#END of bridge.conf

The issues I am facing in the mosquitto MQTT broker are:
1. While publishing messages through mosquitto broker to AWS IoT, some of the messages are getting published on AWS IoT but at the same time, some of the messages are not getting published on AWS IoT.
2. Mosquitto broker is getting frequently disconnected from the AWS IoT.

Please help me to resolve this issue.

@Daedaluz
Copy link
Contributor

Daedaluz commented Sep 7, 2023

It's slightly hard to follow the configuration due to all the formatting.

But since you obviously have intermittment connections / disconnections, one typical suspect in such behaviour is using the same clientid for multiple connections.

Guessing here since there isn't much to walk on. (no logs)

Are you by any chanse using the same config somewhere else?

@rahulpandey-98
Copy link
Author

Thank you for commenting

Here is the complete configuration:

connection awsiot
address a3fu7wrc8e12x7-ats.iot.us-east-1.amazonaws.com:8883

topic $aws/things/+/shadow/update out 1
topic $aws/things/+/bytepayload/update out 1
topic $aws/things/+/shadow/update/delta in 1

bridge_protocol_version mqttv311
bridge_insecure false

cleansession true
clientid bridgeawsiot
start_type automatic
notifications false
log_type all

allow_anonymous true
listener 1883

bridge_cafile /etc/mosquitto/certs/rootCA.pem
bridge_certfile /etc/mosquitto/certs/cert.crt
bridge_keyfile /etc/mosquitto/certs/private.key

1. How to make clientid dynamic for each connection
2. Yes I have made two instance and using the some config

@Daedaluz
Copy link
Contributor

Daedaluz commented Sep 7, 2023

I haven't used AWS IoT and I don't know your setup requirements, so i cannot give an exact answer on how to make it dynamic, that said;

just changing the clientid option might be enough depending if aws enforce clientid through the cert or not.

If the clientid is checked in the cert, then you'd have to generate another set of cert / keys and have clientid, bridge_certfile, bridge_keyfile options set accordingly.

@rahulpandey-98
Copy link
Author

Thank you for the response. Same clientid for more than one instance was one of the reason. It also seems that issue was due to MQTT version. I updated MQTT version from 3.1.1. to 5.0 and now its working

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants