News:

  • September 26, 2026, 08:02:46 AM

Login with username, password and session length

Author Topic: MQTTSUB Hang  (Read 6151 times)

belias

  • Full Member
  • ***
  • Posts: 36
MQTTSUB Hang
« on: December 06, 2021, 12:47:33 PM »
Hi All,

I'm having a random issue (this is the 3rd time I've seen it over about a 6 month period) where MQTTSUB will hang, and not provide any indication that it's stopped working.

In this case, the hang was was caused by rebooting the MQTT broker.  After it came back online, the PLC had triggered my own validity check routine (looking for a change in MQTT data every x minutes).

I opened Do-More and there were no errors showing for the PLC, all I/O parameters were normal.  In the MQTTSUB instruction, both the On Success and On Error bits were off.  Changing the PLC from Run to Program to Run again didn't solve it, and using the "Re-Initialize PLC I/O" didn't solve it.  The extended error DWORD always stayed at 0.  After a power cycle, it immediately began working as normal.

I guess I can (should?) monitor for the case where the "On Success" bit turns off (rather than the "On Error" bit turning on), but even if I did...what instruction could I use to reset the MQTTSUB routine?


Any help would be great.  Thank you!


- Brian

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: MQTTSUB Hang
« Reply #1 on: December 06, 2021, 01:58:50 PM »
Hi All,

I'm having a random issue (this is the 3rd time I've seen it over about a 6 month period) where MQTTSUB will hang, and not provide any indication that it's stopped working.

In this case, the hang was was caused by rebooting the MQTT broker.  After it came back online, the PLC had triggered my own validity check routine (looking for a change in MQTT data every x minutes).

I opened Do-More and there were no errors showing for the PLC, all I/O parameters were normal.  In the MQTTSUB instruction, both the On Success and On Error bits were off.  Changing the PLC from Run to Program to Run again didn't solve it, and using the "Re-Initialize PLC I/O" didn't solve it.  The extended error DWORD always stayed at 0.  After a power cycle, it immediately began working as normal.

I guess I can (should?) monitor for the case where the "On Success" bit turns off (rather than the "On Error" bit turning on), but even if I did...what instruction could I use to reset the MQTTSUB routine?


Any help would be great.  Thank you!


- Brian

Generally things like this are gaps in the protocol state machine, where due to an unexpected situation it drops into a state it doesn't recover from. They are generally very easy to fix, once identified, but since they are usually the result of an exception condition, they can be hard to identify.

The MQTT client has a pretty extensive list of status info that can be dumped to DMLogger. We can sometimes use that info figure out what had to happen to get stuck. You can enable those messages by setting $EnableMsgDump (ST36) to true and $SysMsgLevel (DST61) to 2.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO