question

CSN avatar image
0 Likes"
CSN asked CSN commented

Problem with MQTT

Hello, When I use FlexScript to establish an MQTT connection, sometimes the connection can become unstable and disconnect. When the connection is restored, FlexSim will reconnect, but FlexSim will not automatically subscribe to messages after reconnecting. If the model is in a stopped state at this time, is there a way to make FlexSim automatically subscribe? Or, besides ondrawtrigger, is there a trigger that can trigger logic when the model is in a stopped state?

FlexSim 23.2.3
mqtt
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeanette F avatar image Jeanette F ♦♦ commented ·

@Luciano Cavallero, @Tancredi Canonico, @Fiorenzo A, can you please take a look at this emulation-related question?

0 Likes 0 ·
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered CSN commented

MQTT should handle the disconnect/reconnect for you but you should set cleanStart to 0 when you initialize the client and make sure you're using a clientID string that isn't empty.

Also you shouldn't need a loop (which you seem to be asking for) - the messaging is handled asynchronously once subscribed, independently of any draw/model events.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

CSN avatar image CSN commented ·

Thank you for your reply.

0 Likes 0 ·
Tancredi Canonico avatar image
0 Likes"
Tancredi Canonico answered CSN commented

Are you using the MQTT class or MQTT connection in the Emulation module?

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

CSN avatar image CSN commented ·

Yes, it is.

0 Likes 0 ·