rdcore icon indicating copy to clipboard operation
rdcore copied to clipboard

MQTT API Gateway URL not being read - nothing published to mqtt

Open gkelle opened this issue 9 months ago • 0 comments

I set up the Rdcore-API-Gateway as per the docs and didn't see any messages going over MQTT. In my case, the service does not listen on the loopback interface so is not reachable via http://127.0.0.1:8001. My understanding is that I should be able to set a URL using Settings>MQTT in the GUI to define an alternative URL for the gateway.

Poking around, I noticed that the URL value appears to be pulled from "api_gateway_url" as per this line: https://github.com/RADIUSdesk/rdcore/blob/cake4/cake4/rd_cake/src/Controller/ApActionsController.php#L111

Looking elsewhere, it appears that the value defined in the GUI is "api_mqtt_gateway_url" rather than "api_mqtt_gateway" https://github.com/RADIUSdesk/rdcore/blob/cake4/cake4/rd_cake/src/Controller/SettingsController.php#L732

I did a quick hack using the following on rdcore/cake4/rd_cake/src/Controller/ApActionsController.php

    109         //Some default values
    110         $cfg['api_mqtt_enabled'] = false;
    111         $cfg['api_gateway_url'] = 'http://127.0.0.1:8001';
    112 
    113         $want_these = ['api_mqtt_enabled','api_mqtt_gateway_url'];
    114                 $ent_us     = $this->UserSettings->find()->where(['UserSettings.user_id' => -1])->all();
    115 
    116                 foreach($ent_us as $s){
    117                     $s_name     = $s->name;
    118                     $s_value    = $s->value;
    119                     if(in_array($s_name,$want_these)){
    120                         $cfg["$s_name"] = $s_value;
    121                     }
    122                 }
    123 
    124         $cfg['api_gateway_url'] = $cfg['api_mqtt_gateway_url'];
    125         $client = new Client();

With that in place, I started to see messages passing through mqtt.

With the way the existing code is, it looks like it's just going to always default to http://127.0.0.1:8001 rather than using the value from the GUI.

gkelle avatar Apr 15 '25 22:04 gkelle