MQTT-bridge-mosquitto not working with AWS Iot

Hi,

   we have implemented https://github.com/nRFCloud/MQTT-bridge-mosquitto in our AWS account. but in we are getting error like 

1736241683: Client nrfcloud-bridge-local closed its connection.
MqttBridgeContainer
1736241683: Connecting bridge nrfcloud-bridge (mqtt.nrfcloud.com:8883)
MqttBridgeContainer
1736241652: Client nrfcloud-bridge-local closed its connection.
MqttBridgeContainer
1736241652: Connecting bridge nrfcloud-bridge (mqtt.nrfcloud.com:8883)
MqttBridgeContainer
1736241621: Client nrfcloud-bridge-local closed its connection.
MqttBridgeContainer
1736241621: Connecting bridge nrfcloud-bridge (mqtt.nrfcloud.com:8883)

   CloudFormation stack is successfully deployed. there is no error in that.

   Also it was working fine around 24 hours ago. suddenly we were not getting any data in AWS so we tried to redeploy it but the result is the same.

Thanks,  

Parents
  • Hi,

    How many devices do you have in total? How many devices are affected by this "not able to connect" problem?

    Are affected devices (that try to connect) located in the same physical location?

    Best regards,
    Dejan

  • Hi,

    We have 50+ devices and all devices are not able to connect. Our devices are in 2-3 countries like Poland, Spain etc.

    Thanks 

  • Hi Neel,

    Although there is no fix for MQTT Bridge yet, we have verified that mosquitto MQTT broker (which the bridge uses) works if it is installed and configured manually.

    Fortunately, there is a workaround implementation which you can try to follow. It installs and configures Mosquitto locally on a Windows 11 machine. You can adapt these instructions for use on Linux or in Docker containers as you see fit.

    The MQTT Bridge must be already installed, because it reuses local certs the bridge creates. The ECS task of the bridge does need to be running. You can stop it using the AWS Console by clicking “Update Service” on the ECS cluster’s nrfcloud-mqtt-bridge-MqttBridgeService…, and setting the “Desired tasks” to 0.

    1. In your AWS account and region where the MQTT Bridge is installed, go to the Systems Manager Parameter Store console.

    1. Copy the certificates in the IotCert and IotKey parameters into files named local_IotCert.txt and local_IotKey.txt. Ensure the last line of each file has an end-of-line character at the end.

    1. Using the REST API, create an MQTT Team device. See https://api.nrfcloud.com/v1#tag/Mqtt-Team-Devices/operation/CreateMqttTeamDevice.

    1. Store the 3 certificates returned in files named nrfcloud_caCert.crt, nrfcloud_clientCert.txt, and nrfcloud_privateKey.txt.

    1. Change all literal strings "\n" to end-of-line characters in all 3 files. Ensure the last line of each file has an end-of-line character at the end.

    1. Download https://mosquitto.org/files/binary/win64/mosquitto-2.0.11-install-windows-x64.exe

    1. Install it to the default location

    1. Add "%ProgramFiles%\Mosquitto" (without quotes) to the Windows PATH

    1. Create a directory from where you will run Mosquitto and store configuration files, such as "C:\Mosquitto".

    2. Open a Command Prompt window and "cd" to the run directory you created.

    3. Enter "mosquitto -h". You should see the help page and "mosquitto version 2.0.11" displayed.

    4. Copy the attached "config.txt" into that directory.

    5. Replace the "remote_clientid" with the ID of the MQTT Team device you created, e.g. "mqtt-team-…".

    6. Replace the "address" of the "connection iot-bridge" (not the "connection nrfcloud-bridge") with the AWS IoT Domain configuration name for your AWS account and region.

    7. Create a subdirectory "config".

    8. Copy the 5 files you created above, into that "config" directory. (local_IotCert.txt, local_IotKey.txt, nrfcloud_ca.crt, nrfcloud_clientCert.txt, nrfcloud_privateKey.txt)

    9. In the run directory, start the mosquitto broker with the command: "mosquitto -v -c config.txt".

    10. Verify that MQTT messages sent by devices in your nrfCloud team appear on your AWS account and region on the MQTT topics "data/#" as described in republished topics.


    Please find uploaded example of config.txt file.  

    connection nrfcloud-bridge
    address mqtt.nrfcloud.com:8883
    local_clientid nrfcloud-bridge-local
    # Replace the example below with the device ID of an MQTT Team device you create
    remote_clientid mqtt-team-73a78bf2-6159-4692-87b3-6ae194cb9778-0619ece8-0463-446b-a583-54b7105212df
    bridge_protocol_version mqttv311
    bridge_cafile config/nrfcloud_caCert.txt
    bridge_certfile config/nrfcloud_clientCert.txt
    bridge_keyfile config/nrfcloud_privateKey.txt
    bridge_insecure false
    cleansession true
    start_type automatic
    notifications false
    log_type all
    log_timestamp true
    
    topic m/# in 1 data/ prod/(team-ID)/
    
    connection iot-bridge
    # Replace the example below with your AWS IoT Domain configuration name
    address a3shl1aeabcdef-ats.iot.us-west-1.amazonaws.com:8883
    bridge_cafile config/nrfcloud_caCert.txt
    bridge_certfile config/local_IotCert.txt
    bridge_keyfile config/local_IotKey.txt
    bridge_insecure false
    cleansession true
    start_type automatic
    notifications false
    log_type all
    log_timestamp true
    
    topic # out 1
    

    Best regards,
    Dejan

  • Hi Neel,

    Have you made any progress? Can you provide an update on a current status? 

    Best regards,
    Dejan

  • Hi,

    While using this config file, we are facing the below error.

    Client nrfcloud-bridge-local disconnected: protocol error.
    Client local.DESKTOP-UQS9RRA.iot-bridge disconnected: protocol error.

  • Hi,

    We have tested internally using your config and certificate files and could not reproduce the issue. 
    Below are some updated instructions. Can you please try again by following instructions shown below?

    1. In your AWS account and region where the MQTT Bridge is installed, go to the Systems Manager Parameter Store console.

    2. Copy the certificates in the IotCert and IotKey parameters into files named local_IotCert.txt and local_IotKey.txt. Ensure the last line of each file has an end-of-line character at the end.

    3. Using the REST API, create an MQTT Team device. See nRF Cloud REST API documentation

    4. Store the 3 certificates returned in files named nrfcloud_caCert.txt, nrfcloud_clientCert.txt, and nrfcloud_privateKey.txt.

    5. Change all literal strings "\n" to end-of-line characters in all 3 files. Ensure the last line of each file has an end-of-line character at the end.

    6. Download mosquitto.org/.../mosquitto-2.0.11-install-windows-x64.exe

    7. Install it to the default location

    8. Add "%ProgramFiles%\Mosquitto" (without quotes) to the Windows PATH

    9. Create a directory from where you will run Mosquitto and store configuration files, such as "C:\Mosquitto".

    10. Open a Command Prompt window and "cd" to the run directory you created.

    11. Enter "mosquitto -h". You should see the help page and "mosquitto version 2.0.11" displayed.

    12. Copy the attached "config.txt" into that directory.

    13. Look for the “# Replace…” comment lines and replace the example strings with the correct strings for your case.

    14. Create a subdirectory "config".

    15. Copy the 5 files you created above, into that "config" directory. (local_IotCert.txt, local_IotKey.txt, nrfcloud_ca.crt, nrfcloud_clientCert.txt, nrfcloud_privateKey.txt)

    16. In the run directory, start the mosquitto broker with the command: "mosquitto -v -c config.txt".

    17. Verify that MQTT messages sent by devices in your nrfcloud team appear on your AWS account and region on the MQTT topics "data/#" as described in republished topics documentation.

    Please find uploaded revised 

    If you still experience issue, please consider trying on another computer and look thoroughly for any potential networking issue which may block some traffic.

    Best regards,
    Dejan

  • Hi,

    The issue in MQTT bridge should be fixed now. Fixed mqtt bridge mosquitto is available in the same location as it was previously. For re-deploying the bridge, you should follow the instructions provided in MQTT bridge mosquitto, get and compile the newest code, and use the --reset option to create a new MQTT Team device and new local credentials as described on the linked page. If this works, then you do not need a workaround anymore. You can also delete all account-* and mqtt-team-* devices on your team that you do not use, except mqtt-team-* device that will be newly created by your latest deployment. That device ID can be found in AWS Systems Manager Parameter Store in the parameter NrfCloudMqttTeamDeviceId. 

    Best regards,
    Dejan

Reply
  • Hi,

    The issue in MQTT bridge should be fixed now. Fixed mqtt bridge mosquitto is available in the same location as it was previously. For re-deploying the bridge, you should follow the instructions provided in MQTT bridge mosquitto, get and compile the newest code, and use the --reset option to create a new MQTT Team device and new local credentials as described on the linked page. If this works, then you do not need a workaround anymore. You can also delete all account-* and mqtt-team-* devices on your team that you do not use, except mqtt-team-* device that will be newly created by your latest deployment. That device ID can be found in AWS Systems Manager Parameter Store in the parameter NrfCloudMqttTeamDeviceId. 

    Best regards,
    Dejan

Children
No Data
Related