Mosquitto broker on android 9 hotspot = random broker address



  • after some years of great and reliable service, my old Android 7 phone, used as hotspot and mosquitto broker, has decided to retire himself.

    In my previous setup, Mosquitto runs in a termux shell on boot, and with an app/tasker plugin -mqtt client-, I can intercept messages sent from an esp32cam client (I use it as a PIR alarm), then send me sms through tasker and a mail with the captured image through wifi.

    On android 7 the hotspot address is always 192.168.43.1 and for months I had no problems.

    Now I have a new phone as hotspot, with Android 9, but I can't replicate my setup: the gateway address, so the mosquitto broker address, changes randomly at every new connection, and I can't fix it on the esp32 and on the mqtt client app.



  • Solved after thinking about it a bit more:

    On mqtt client app (that runs on the android hotspot) i've set the broker address as "localhost".

    On the ESP32 cam alarm add this lines after the wifi connection

    int mqtt_server = WiFi.gatewayIP(); //ugly but works
    client.setServer(mqtt_server, 1883);
    

    hope this helps others that want to run mqtt broker directly on their android hotspot




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2