Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Changing Mqtt Server Configuration Doesn't Work

Hello,

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 mqtt.server=mqtt.googleapis.com:433 and checked that the configuration was actually updated:

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

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 mqtt.googleapis.com:8883
[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?

Comments

  • 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

    Correct..
    Looking at https://github.com/mongoose-os-libs/gcp/blob/master/src/mgos_gcp.c#L241-L242, 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 = "mqtt.googleapis.com"; */, 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.googleapis.com:8883
      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.