Topic: Change Broker Ip Address on runtime

Hi Forum,

When using a mqt client.
Is there a way programmatically to change the Broker IP address which the client is pointing to on runtime?
Once the broker ip address is change what needs to be done? Maybe restart the client?
What is the proper function/methods to call/execute?

Thank you

Share

Re: Change Broker Ip Address on runtime

Hello rlev,

With wolfMQTT, you can change the broker IP during the network connect using

MqttClient_NetConnect

. If the client was already connected to a different broker, you would need to first need to disconnect (

MqttClient_NetDisconnect

)

Re: Change Broker Ip Address on runtime

There are many static data resources in the current MQTT library (v1.9.0) that are shared by all clients. the semaphore lock that is connected to the "static MqttProp clientPropStack[MQTT_MAX_PROPS]". This resource ran out while just TWO clients were active, thus as a workaround, the MQTT_MAX_PROPS value had to be raised by multiplying the default value by the number of clients.

Re: Change Broker Ip Address on runtime

Hi horroraround,

Thanks for joining the wolfSSL Forums. The max props define is set to 30, and can be overridden by defining MQTT_MAX_PROPS at build time. This was a design decision that allowed us to keep the library requirements small and still allow flexibility for applications.

Alternatively, if your application can tolerate dynamic memory usage, the library can allocate property structures dynamically using malloc. Just add the configuration define WOLFMQTT_DYN_PROP to enable this feature.

Thanks,
Eric - wolfSSL Support