Scheduling a downlink with MQTT

I have a RAK2287 gateway/application server/network server. I have successfully written a python script to access the uplink messages from my node, using paho-mqtt.

I would now like to schedule downlinks using MQTT. I have found this page ( and I’ve attempted to follow it, using paho-mqtt’s connect(), subscribe() and publish() commands. Unfortunately, despite my best efforts, I can’t schedule a downlink.

I don’t know what’s wrong because I don’t know of anywhere in chirpstack I can go to see why my MQTT messages are being rejected. Can anyone help with debugging?

This is the basics of my code:

import paho.mqtt.client as mqtt
import json
import base64

def on_connect(client,userdata,flags,rc):
    print("Connected with result code:"+str(rc))

mqttc= mqtt.Client()


datatosend = b'\x01\x02\x04\x00\x00\x00\x00'
datatosendb64 = base64.b64encode(datatosend)

packettosend = {
    "confirmed": 'true',
    "fPort": 3,
    "data": str(datatosendb64)

json_packettosend = json.dumps(packettosend)

mqttc.publish("application/4/device/MYEUI/command/down", json_packettosend, 0, False)

Many thanks for any help you can offer.

Might sound stupid, but have you tried quoting your base64 string?
I’d look at the application-server logs for errors

Yes, I’ve printed the entire json structure. It looks like this:
{"confirmed": "true", "fPort": 3, "data": "AQIEAAAAAA=="}

Can you advise on how I can access the application server logs?