I've spent the past week banging my head against my monitor, trying to figure out why my PUBLISH messages wouldn't always get sent. Here's the code structure:
1. Stage with SUBSCRIBE for 4 subscriptions.
2. Each time the subscription receives a message I SGSET to a stage specific to the subscription and PUBLISH an appropriate message back to the broker, then I SGRST the stage.
What I have been finding is that the first PUBLISH takes a long time to work - in fact it typically logs a connect-timeout (followed by a successful retry) attempting to reach the broker. Subsequent Subscribed messages to the same Topic are received by the PLC (according to the log) but don't get processed - it's like it hangs.
If I process a different subscription I get the same behavior - one (usually with a timeout) PUBLISH and then it stops responding.
In order to fix this I've had to add a second Device that points to the same broker, and I've changed the SUBSCRIBE message to use the new device. Now everything works just fine, with no delays
It seems as though the device gets itself in a mess when I'm PUBLISHing within a loop that contains a SUBSCRIBE.
Andrew.