Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

Changing Mqtt Server Configuration Doesn't Work


I am trying to connect an ESP32 to Google IoT Core's alternate mqtt port since my university's firewall is blocking the default one.

I have tried using mos config-set and checked that the configuration was actually updated:

C:\Users\gwave\Desktop\ESP_Programming_V3>mos config-get mqtt.server

Yet, the ESP is still trying to connect to the default port :| :

[Sep 12 16:12:11.298] mgos_mqtt_global_con MQTT connecting to
[Sep 12 16:12:29.099] mgos_mqtt_ev         MQTT TCP connect error (-11)
[Sep 12 16:12:29.099] mgos_mqtt_ev         MQTT Disconnect

Does anyone have any insight as to why this is not working or know whether there is an alternative method to achieve what I'm trying to do?


  • SergeySergey Dublin, Ireland

    As far as I remember, the Google IoT lib, gcp, constructs the backend address from the gcp config object, not mqtt.
    Could you mos config-get gcp and see ?

  • Hey @Sergey,

    As far as I can tell, mos config-get gcp contains nothing related to the mqtt port:

      "device": "esp32_4A3758",
      "enable": true,
      "key": "gcp-esp32_esp32_4A3758.key.pem",
      "project": "iot-testing123",
      "region": "us-central1",
      "registry": "iot-registry",
      "token_ttl": 3600
  • SergeySergey Dublin, Ireland

    Looking at, apparently the gcp startup code always overrides mqtt.server setting.
    Could you comment out that line, rebuild the fw and try , pls ?

  • So, I forked the gcp library, commented out /** mcfg.server = ""; */, and added the new Github url to my mos.yml file.
    Unfortunately, after rebuilding and flashing, I still get the same effect.

    I noticed that the default mqtt server configuration gets set when I run the mos gcp-iot-setup command:

    Updating config:
      gcp.device = esp32_4A3758
      gcp.enable = true
      gcp.key = gcp-esp32_4A3758.key.pem
      gcp.project = iot-testing123
      gcp.region = us-central1
      gcp.registry = iot-registry
      mqtt.enable = true
      mqtt.server =
      mqtt.ssl_ca_cert = ca.pem
      sntp.enable = true
    Setting new configuration...
    Saving and rebooting...

    If there is a way to trace what code that command executes, maybe I could modify the configuration there?

Sign In or Register to comment.