Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gkelle opened this issue Apr 15, 2025 · 0 comments
Open

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

gkelle opened this issue Apr 15, 2025 · 0 comments

Comments

@gkelle
Copy link

gkelle commented Apr 15, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant