MQTT Plugin not sending updates unless connected

I've got an MQTT application running on an ESP32 device monitoring printer status (print status, % complete, temps, etc.) and it works fine while I'm connected to the RPi on my computer. However if I disconnect from the printer the MQTT information no longer gets updated even though the printer is still running and the MQTT connection hasn't dropped. Just no updates.

Am I missing a configuration option or is the behavior by design?

I don't think that's normal, but could be. If you "disconnect from the printer" how is it still printing? If printing from SD card that may change the logic and because OctoPrint isn't connected to the printer to get status updates, it doesn't have any information to send via MQTT.

I don't think it matters but I'm running Klipper as the printer firmware.

With some more testing what you say makes sense, including the part about printing from the SD card. Though if I do a print that way and disconnect & then reconnect the information doesn't update either though the print obviously runs to completion

I guess what is/was puzzling is that if I do a "soft" disconnect by closing the browser everything continues to run even though OctoPrint has no place to send the updates. I'm also running TouchUI on the display connected to the RPi so don't know how that factors in there. Though the Touch/UI interface shows "Offline" when I disconnect via the browser.

I'm fine with the data stream going away so long as I understand the behavior and can provide answers or explain the limitations to any other users. I may need to add some additional code to handle the unexpected scenarios as well as capture some of the printer events I'm currently ignoring.

The difference here is you're web client is "disconnecting" from the OctoPrint server, but the server itself is still "connected" to the printer getting status updates. The MQTT server-side code is then able to react to those updates and forward them as publications to your MQTT server.

BTW, there is a pull request I believe to the MQTT plugin in regards to the connect/disconnect workflow so it may help in the situation where there is a loss in connection in some regard. I haven't had the chance to really review those changes yet, but may help in whatever programming work-around you need to implement. I am one of the contributor/maintainers of the MQTT plugin.